MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / updateObject

Function updateObject

packages/plugins/workos-vault/src/sdk/testing.ts:136–169  ·  view source on GitHub ↗
(opts: {
    readonly id: string;
    readonly value: string;
    readonly versionCheck?: string;
  })

Source from the content-addressed store, hash-verified

134 });
135
136 const updateObject = (opts: {
137 readonly id: string;
138 readonly value: string;
139 readonly versionCheck?: string;
140 }): Effect.Effect<WorkOSVaultObject, TestWorkOSVaultError> =>
141 Effect.gen(function* () {
142 const current = [...objects.values()].find((o) => o.id === opts.id);
143 if (!current) {
144 return yield* notFound(`Object "${opts.id}" not found`);
145 }
146 if (conflictPending && current.name.endsWith("/secrets/conflict")) {
147 conflictPending = false;
148 return yield* conflict(`Injected conflict for "${opts.id}"`);
149 }
150 if (opts.versionCheck && current.metadata.versionId !== opts.versionCheck) {
151 return yield* conflict(`Version mismatch for "${opts.id}"`);
152 }
153
154 const nextVersion = current.metadata.versionId.replace(
155 /v(\d+)$/,
156 (_, version) => `v${Number(version) + 1}`,
157 );
158 const next: WorkOSVaultObject = {
159 ...current,
160 value: opts.value,
161 metadata: {
162 ...current.metadata,
163 updatedAt: new Date(),
164 versionId: nextVersion,
165 },
166 };
167 objects.set(current.name, next);
168 return next;
169 });
170
171 const deleteObject = (opts: { readonly id: string }): Effect.Effect<void, TestWorkOSVaultError> =>
172 Effect.gen(function* () {

Callers 1

Calls 5

conflictFunction · 0.85
valuesMethod · 0.80
setMethod · 0.80
notFoundFunction · 0.70
replaceMethod · 0.65

Tested by

no test coverage detected