(ns: string)
| 139 | const ctx = yield* Effect.context<R>() |
| 140 | const seedCache = new Map<string, Effect.Effect<void>>() |
| 141 | const makeSeedEffect = (ns: string) => { |
| 142 | const markerId = ns === "primary" ? importedMarkerId : `${importedMarkerId}::${ns}` |
| 143 | return Effect |
| 144 | .promise(() => |
| 145 | container |
| 146 | .item(markerId, markerId) |
| 147 | .read<{ id: string }>() |
| 148 | .then(({ resource }) => Option.fromNullishOr(resource)) |
| 149 | ) |
| 150 | .pipe( |
| 151 | Effect.flatMap((marker) => { |
| 152 | if (Option.isSome(marker)) return Effect.void |
| 153 | return InfraLogger.logInfo(`Creating mock data for ${name} (namespace: ${ns})`).pipe( |
| 154 | Effect.andThen(seed!), |
| 155 | Effect.flatMap((m) => |
| 156 | Effect.flatMapOption( |
| 157 | Effect.succeed(toNonEmptyArray([...m])), |
| 158 | (a) => bulkSetInternal(a, ns).pipe(Effect.orDie) |
| 159 | ) |
| 160 | ), |
| 161 | Effect.andThen( |
| 162 | Effect.promise(() => |
| 163 | container.items.create({ |
| 164 | _partitionKey: markerId, |
| 165 | id: markerId, |
| 166 | ttl: -1 |
| 167 | }) |
| 168 | ) |
| 169 | ), |
| 170 | Effect.provide(ctx), |
| 171 | Effect.orDie |
| 172 | ) |
| 173 | }), |
| 174 | Effect.withLogSpan(`Cosmos.seedCheck ${name} in ${ns} [effect-app/infra/Store]`), |
| 175 | annotateDb({ |
| 176 | operation: "seed", |
| 177 | system: "cosmosdb", |
| 178 | collection: containerId, |
| 179 | namespace: ns, |
| 180 | entity: name |
| 181 | }) |
| 182 | ) |
| 183 | } |
| 184 | const seedNamespace = Effect.fn("seedNamespace")(function*(ns: string) { |
| 185 | if (!seed) return |
| 186 | let cached = seedCache.get(ns) |
no test coverage detected
searching dependent graphs…