@nyrra/prismantix-cli 0.0.3-next.3 → 0.0.3-next.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,14 +10,16 @@ prismantix ontology list
10
10
  prismantix object list healthcare
11
11
  prismantix object details deviations
12
12
  prismantix records pull --client NVO
13
- prismantix records generate --client NVO --ontology pharma
13
+ prismantix records generate --client NVO --ontology operations
14
+ prismantix records generate --client BSX --ontology medtech \
15
+ --object device-installations --object service-events --count 10
14
16
  prismantix records status <operation-id>
15
17
  prismantix records cancel <operation-id>
16
18
  ```
17
19
 
18
20
  Every command supports `--json`. JSON mode reserves stdout for one result; progress and diagnostics go to stderr. `--api-base` overrides `PRISMANTIX_API_BASE`, whose default is `https://api.prismantix.com`.
19
21
 
20
- `records generate` waits for completion by default with a 30-minute timeout. Use `--no-wait`, `--timeout`, and `--poll-interval` for operational control. A completed operation exits 0. A failed operation or an operation canceled while this command is waiting exits 1 with a typed error; an explicitly acknowledged `records cancel` request exits 0.
22
+ `records generate` waits for completion by default with a 30-minute timeout. With no `--object` flags it preserves the complete-ontology defaults. For a targeted run, repeat `--object` with catalog object slugs and provide `--count` (1-100 records per selected object); prerequisites are resolved automatically and existing prerequisite records are reused. Use `--no-wait`, `--timeout`, and `--poll-interval` for operational control. Terminal output includes requested, persisted, rejected, and failed counts per object. A completed operation exits 0. A failed operation or an operation canceled while this command is waiting exits 1 with a typed error; an explicitly acknowledged `records cancel` request exits 0.
21
23
 
22
24
  `records pull` creates and waits for a CSV-bundle export, then writes `manifest.json` and its files under `./prismantix-exports/<canonical-client-id>/<export-id>/`. Use `--output`, repeatable `--table`, `--timeout`, and `--poll-interval` when needed.
23
25
 
@@ -29,6 +31,11 @@ Foundry import is intentionally not bundled with the anonymous public CLI. Autho
29
31
  npm login --scope=@shpitdev --registry=https://registry.npmjs.org
30
32
  prismantix plugins install @shpitdev/prismantix-ontology-interop
31
33
  prismantix foundry import --help
34
+ prismantix foundry dbml --help
32
35
  ```
33
36
 
37
+ `foundry import` writes three files into the output directory: `ontology.mts` (one self-contained `@osdk/maker` module), `diagnostics.json`, and `diagnostics.md`. Conversion is lossy, so read the diagnostics before treating `ontology.mts` as hand-authored OAC.
38
+
39
+ `foundry dbml` reads the same Foundry export and writes exactly one standard `ontology.dbml` file that dbdiagram.io imports directly, for reviewing an export as an entity-relationship diagram.
40
+
34
41
  CI must use an npm token scoped to read restricted `@shpitdev` packages. Never commit a populated user `.npmrc`.
package/dist/api.d.ts CHANGED
@@ -147,12 +147,14 @@ declare const RecordGenerationStatusSchema: Schema.Struct<{
147
147
  readonly issues: Schema.$Array<Schema.String>;
148
148
  readonly objectSlug: Schema.String;
149
149
  readonly persistedCount: Schema.Number;
150
+ readonly rejectedCount: Schema.Number;
150
151
  readonly requestedCount: Schema.Number;
151
152
  readonly state: Schema.Literals<readonly ["queued", "running", "completed", "failed", "canceled"]>;
152
153
  }>>;
153
154
  readonly totals: Schema.Struct<{
154
155
  readonly objectCount: Schema.Number;
155
156
  readonly persistedCount: Schema.Number;
157
+ readonly rejectedCount: Schema.Number;
156
158
  readonly requestedCount: Schema.Number;
157
159
  }>;
158
160
  }>;
@@ -183,7 +185,10 @@ type ApiClientError = ApiConfigurationError | ApiDecodeError | ApiHttpError | Ap
183
185
  interface PrismantixApiClientService {
184
186
  readonly cancelRecordGeneration: (operationId: string) => Effect.Effect<RecordGenerationStatus, ApiClientError>;
185
187
  readonly createExport: (clientId: string) => Effect.Effect<ExportCreated, ApiClientError>;
186
- readonly createRecordGeneration: (clientId: string, ontologyId: string, idempotencyKey: string) => Effect.Effect<RecordGenerationCreated, ApiClientError>;
188
+ readonly createRecordGeneration: (clientId: string, ontologyId: string, idempotencyKey: string, objects?: readonly {
189
+ readonly count: number;
190
+ readonly objectSlug: string;
191
+ }[]) => Effect.Effect<RecordGenerationCreated, ApiClientError>;
187
192
  readonly getExportStatus: (exportId: string) => Effect.Effect<ExportStatus, ApiClientError>;
188
193
  readonly getFile: (exportId: string, tableName: string) => Effect.Effect<Response, ApiClientError>;
189
194
  readonly getManifest: (exportId: string) => Effect.Effect<ExportManifest, ApiClientError>;
package/dist/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,cAAc,EACd,OAAO,EACP,MAAM,EACN,KAAK,EAGL,MAAM,EACN,MAAM,QAAQ,CAAC;AAOhB,QAAA,MAAM,kBAAkB;;;;;;;;;EAStB,CAAC;AACH,MAAM,WAAW,kBAAmB,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,kBAAkB,CAAC;IACxF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAED,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;EASxB,CAAC;AACH,MAAM,WAAW,cAAe,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,oBAAoB,CAAC;CAAG;AAW1F,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;EActB,CAAC;AACH,MAAM,WAAW,YAAa,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,kBAAkB,CAAC;CAAG;AAEtF,QAAA,MAAM,mBAAmB;;;;EAIvB,CAAC;AACH,UAAU,aAAc,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,mBAAmB,CAAC;CAAG;AAEjF,QAAA,MAAM,qBAAqB;;;;;EAKzB,CAAC;AACH,UAAU,eAAgB,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,qBAAqB,CAAC;CAAG;AAErF,QAAA,MAAM,2BAA2B;;;;;;;;EAQ/B,CAAC;AACH,UAAU,qBAAsB,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,2BAA2B,CAAC;CAA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AAS,EAAE,MAAM,KACb,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IAC7C,QAAQ,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;IAC1F,QAAQ,CAAC,iBAAiB,EAAE,CAC3B,UAAU,EAAE,MAAM,KACd,MAAM,CAAC,MAAM,CAAC,oBAAoB,EAAE,cAAc,CAAC,CAAC;IACzD,QAAQ,CAAC,mBAAmB,EAAE,CAC7B,WAAW,EAAE,MAAM,KACf,MAAM,CAAC,MAAM,CAAC,sBAAsB,EAAE,cAAc,CAAC,CAAC;IAC3D,QAAQ,CAAC,cAAc,EAAE,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,eAAe,EAAE,EAAE,cAAc,CAAC,CAAC;IACzF,QAAQ,CAAC,mBAAmB,EAAE,CAC7B,UAAU,EAAE,MAAM,KACd,MAAM,CAAC,MAAM,CAAC,SAAS,qBAAqB,EAAE,EAAE,cAAc,CAAC,CAAC;CACrE;;AAED,qBAAa,mBAAoB,SAAQ,wBAGC;CAAG;AAE7C,UAAU,+BAA+B;IACxC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC;IACxD,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAClC;AAaD,eAAO,MAAM,4BAA4B,GAAI,UAAS,+BAAoC,mEA4GxF,CAAC"}
package/dist/api.js CHANGED
@@ -113,12 +113,14 @@ const RecordGenerationStatusSchema = Schema.Struct({
113
113
  issues: Schema.Array(Schema.String),
114
114
  objectSlug: Schema.String,
115
115
  persistedCount: Schema.Number,
116
+ rejectedCount: Schema.Number,
116
117
  requestedCount: Schema.Number,
117
118
  state: GenerationStateSchema,
118
119
  })),
119
120
  totals: Schema.Struct({
120
121
  objectCount: Schema.Number,
121
122
  persistedCount: Schema.Number,
123
+ rejectedCount: Schema.Number,
122
124
  requestedCount: Schema.Number,
123
125
  }),
124
126
  });
@@ -138,10 +140,10 @@ export class ApiDecodeError extends Schema.TaggedError()("ApiDecodeError", {
138
140
  export class PrismantixApiClient extends Context.Service()("@prismantix/cli/PrismantixApiClient") {
139
141
  }
140
142
  const apiConfig = (apiKeyOverride) => Config.all({
141
- apiBaseUrl: Config.withDefault(Config.nonEmptyString("PRISMANTIX_API_BASE"), DEFAULT_API_BASE_URL),
143
+ apiBaseUrl: Config.withDefault(Config.NonEmptyString("PRISMANTIX_API_BASE"), DEFAULT_API_BASE_URL),
142
144
  apiKey: apiKeyOverride
143
145
  ? Config.succeed(Redacted.make(apiKeyOverride))
144
- : Config.redacted("PRISMANTIX_API_KEY"),
146
+ : Config.Redacted("PRISMANTIX_API_KEY"),
145
147
  });
146
148
  export const makePrismantixApiClientLayer = (options = {}) => Layer.effect(PrismantixApiClient, Effect.gen(function* () {
147
149
  const config = yield* apiConfig(options.apiKey).pipe(Effect.mapError(() => new ApiConfigurationError({
@@ -161,8 +163,11 @@ export const makePrismantixApiClientLayer = (options = {}) => Layer.effect(Prism
161
163
  return PrismantixApiClient.of({
162
164
  cancelRecordGeneration: (operationId) => request("POST", `/v1/record-generations/${encodeURIComponent(operationId)}/cancel`, RecordGenerationStatusSchema, {}, true),
163
165
  createExport: (clientId) => request("POST", `/v1/clients/${encodeURIComponent(clientId)}/exports`, ExportCreatedSchema, { body: JSON.stringify({ output: { kind: "csv_bundle" } }) }),
164
- createRecordGeneration: (clientId, ontologyId, idempotencyKey) => request("POST", `/v1/clients/${encodeURIComponent(clientId)}/record-generations`, RecordGenerationCreatedSchema, {
165
- body: JSON.stringify({ ontologyId }),
166
+ createRecordGeneration: (clientId, ontologyId, idempotencyKey, objects) => request("POST", `/v1/clients/${encodeURIComponent(clientId)}/record-generations`, RecordGenerationCreatedSchema, {
167
+ body: JSON.stringify({
168
+ ...(objects === undefined ? {} : { objects }),
169
+ ontologyId,
170
+ }),
166
171
  headers: { "Idempotency-Key": idempotencyKey },
167
172
  }, true),
168
173
  getExportStatus: (exportId) => request("GET", `/v1/exports/${encodeURIComponent(exportId)}`, ExportStatusSchema, {}, true),
@@ -4,6 +4,8 @@ export default class RecordsGenerate extends Command {
4
4
  static flags: {
5
5
  client: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
6
6
  ontology: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
7
+ object: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ count: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
9
  "poll-interval": import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
8
10
  timeout: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
9
11
  wait: import("@oclif/core/interfaces").BooleanFlag<boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/commands/records/generate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAa7C,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IACnD,OAAgB,WAAW,SAAuE;IAClG,OAAgB,KAAK;;;;;;;;MAiBnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA8BjC"}
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/commands/records/generate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAS,MAAM,aAAa,CAAC;AAkD7C,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,OAAO;IACnD,OAAgB,WAAW,SACqE;IAChG,OAAgB,KAAK;;;;;;;;;;MAwBnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA4CjC"}
@@ -4,12 +4,49 @@ import { Effect } from "effect";
4
4
  import { apiFlags, failCommand, printResult, requireValue, runApiEffect, validatePositiveInteger, } from "../../command-support.js";
5
5
  import { DEFAULT_GENERATION_TIMEOUT_MS, DEFAULT_POLL_INTERVAL_MS } from "../../constants.js";
6
6
  import { createRecordGeneration, waitForRecordGeneration } from "../../generation.js";
7
+ import { CliUserError } from "../../errors.js";
8
+ const MAX_RECORDS_PER_OBJECT = 100;
9
+ function requestedObjects(objects, count) {
10
+ if (!objects?.length) {
11
+ if (count !== undefined) {
12
+ throw new CliUserError("invalid_argument", "--count requires at least one --object.");
13
+ }
14
+ return undefined;
15
+ }
16
+ const requestedCount = requireRequestedObjectCount(count);
17
+ const normalized = uniqueObjectSlugs(objects);
18
+ return normalized.map((objectSlug) => ({ count: requestedCount, objectSlug }));
19
+ }
20
+ function requireRequestedObjectCount(count) {
21
+ if (count === undefined) {
22
+ throw new CliUserError("invalid_argument", "--count is required when --object is used.");
23
+ }
24
+ validatePositiveInteger(count, "--count");
25
+ if (count > MAX_RECORDS_PER_OBJECT) {
26
+ throw new CliUserError("invalid_argument", `--count must be ${MAX_RECORDS_PER_OBJECT} or less.`);
27
+ }
28
+ return count;
29
+ }
30
+ function uniqueObjectSlugs(objects) {
31
+ const normalized = objects.map((object) => requireValue(object, "--object").toLowerCase());
32
+ if (new Set(normalized).size !== normalized.length) {
33
+ throw new CliUserError("invalid_argument", "--object values must be unique.");
34
+ }
35
+ return normalized;
36
+ }
7
37
  export default class RecordsGenerate extends Command {
8
- static description = "Append a complete ontology-sized default record set for a client.";
38
+ static description = "Append generated records for selected ontology objects, or the complete ontology by default.";
9
39
  static flags = {
10
40
  ...apiFlags,
11
41
  client: Flags.string({ description: "Client ID.", required: true }),
12
42
  ontology: Flags.string({ description: "Registered ontology ID.", required: true }),
43
+ object: Flags.string({
44
+ description: "Ontology object slug to generate; repeat for multiple objects.",
45
+ multiple: true,
46
+ }),
47
+ count: Flags.integer({
48
+ description: "Records per selected object (1-100; requires --object).",
49
+ }),
13
50
  "poll-interval": Flags.integer({
14
51
  default: DEFAULT_POLL_INTERVAL_MS,
15
52
  description: "Polling interval in milliseconds.",
@@ -31,10 +68,11 @@ export default class RecordsGenerate extends Command {
31
68
  validatePositiveInteger(flags.timeout, "--timeout");
32
69
  const clientId = requireValue(flags.client, "--client");
33
70
  const ontologyId = requireValue(flags.ontology, "--ontology");
71
+ const objects = requestedObjects(flags.object, flags.count);
34
72
  const idempotencyKey = randomUUID();
35
73
  const printOperationId = (operationId) => this.logToStderr(operationId);
36
74
  const result = await runApiEffect(Effect.gen(function* () {
37
- const created = yield* createRecordGeneration(clientId, ontologyId, idempotencyKey);
75
+ const created = yield* createRecordGeneration(clientId, ontologyId, idempotencyKey, objects);
38
76
  yield* Effect.sync(() => printOperationId(created.operationId));
39
77
  if (!flags.wait)
40
78
  return created;
@@ -47,6 +85,13 @@ export default class RecordsGenerate extends Command {
47
85
  this.log(`Record generation ${result.operationId}: ${result.status}`);
48
86
  this.log(`Client: ${result.clientId}`);
49
87
  this.log(`Ontology: ${result.ontologyId}`);
88
+ if ("steps" in result) {
89
+ for (const step of result.steps) {
90
+ this.log(`${step.objectSlug}: ${step.state}; persisted ${step.persistedCount}/${step.requestedCount}; rejected ${step.rejectedCount}`);
91
+ for (const issue of step.issues)
92
+ this.log(` ${issue}`);
93
+ }
94
+ }
50
95
  });
51
96
  }
52
97
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/commands/records/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,OAAO,EAAE,MAAM,aAAa,CAAC;AAU5C,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,OAAO;IACjD,OAAgB,IAAI;;MAAoD;IACxE,OAAgB,WAAW,SAAyC;IACpE,OAAgB,KAAK;;;MAAY;IAEpB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAajC"}
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/commands/records/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,OAAO,EAAE,MAAM,aAAa,CAAC;AAU5C,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,OAAO;IACjD,OAAgB,IAAI;;MAAoD;IACxE,OAAgB,WAAW,SAAyC;IACpE,OAAgB,KAAK;;;MAAY;IAEpB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAmBjC"}
@@ -13,6 +13,11 @@ export default class RecordsStatus extends Command {
13
13
  printResult(this, result, flags.json, () => {
14
14
  this.log(`Record generation ${result.operationId}: ${result.status}`);
15
15
  this.log(`Persisted: ${result.totals.persistedCount}/${result.totals.requestedCount}`);
16
+ for (const step of result.steps) {
17
+ this.log(`${step.objectSlug}: ${step.state}; persisted ${step.persistedCount}/${step.requestedCount}; rejected ${step.rejectedCount}`);
18
+ for (const issue of step.issues)
19
+ this.log(` ${issue}`);
20
+ }
16
21
  });
17
22
  }
18
23
  catch (error) {
@@ -6,7 +6,10 @@ export interface WaitForGenerationOptions {
6
6
  readonly sleep?: (milliseconds: number) => Promise<void>;
7
7
  readonly timeoutMs: number;
8
8
  }
9
- export declare function createRecordGeneration(clientId: string, ontologyId: string, idempotencyKey: string): Effect.Effect<RecordGenerationCreated, import("./api.js").ApiConfigurationError | import("./api.js").ApiHttpError | import("./api.js").ApiTransportError | import("./api.js").ApiDecodeError, PrismantixApiClient>;
9
+ export declare function createRecordGeneration(clientId: string, ontologyId: string, idempotencyKey: string, objects?: readonly {
10
+ readonly count: number;
11
+ readonly objectSlug: string;
12
+ }[]): Effect.Effect<RecordGenerationCreated, import("./api.js").ApiConfigurationError | import("./api.js").ApiHttpError | import("./api.js").ApiTransportError | import("./api.js").ApiDecodeError, PrismantixApiClient>;
10
13
  export declare function getRecordGeneration(operationId: string): Effect.Effect<RecordGenerationStatus, import("./api.js").ApiConfigurationError | import("./api.js").ApiHttpError | import("./api.js").ApiTransportError | import("./api.js").ApiDecodeError, PrismantixApiClient>;
11
14
  export declare function cancelRecordGeneration(operationId: string): Effect.Effect<RecordGenerationStatus, import("./api.js").ApiConfigurationError | import("./api.js").ApiHttpError | import("./api.js").ApiTransportError | import("./api.js").ApiDecodeError, PrismantixApiClient>;
12
15
  export declare function waitForRecordGeneration(created: RecordGenerationCreated, options: WaitForGenerationOptions): Effect.Effect<RecordGenerationStatus, unknown, PrismantixApiClient>;
@@ -1 +1 @@
1
- {"version":3,"file":"generation.d.ts","sourceRoot":"","sources":["../src/generation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,MAAM,EAAgB,MAAM,QAAQ,CAAC;AACnE,OAAO,EACN,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,mBAAmB,EACnB,MAAM,UAAU,CAAC;AAKlB,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,sBAAsB,CACrC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,sNAMtB;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,qNAKtD;AAED,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,qNAKzD;AAED,wBAAgB,uBAAuB,CACtC,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,wBAAwB,uEASjC"}
1
+ {"version":3,"file":"generation.d.ts","sourceRoot":"","sources":["../src/generation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,MAAM,EAAgB,MAAM,QAAQ,CAAC;AACnE,OAAO,EACN,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,mBAAmB,EACnB,MAAM,UAAU,CAAC;AAKlB,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,sBAAsB,CACrC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,SAAS;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAAE,EAAE,sNAM5E;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,qNAKtD;AAED,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,qNAKzD;AAED,wBAAgB,uBAAuB,CACtC,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,wBAAwB,uEASjC"}
@@ -1,10 +1,10 @@
1
1
  import { Cause, Effect, Exit, Option } from "effect";
2
2
  import { PrismantixApiClient, } from "./api.js";
3
3
  import { CliUserError } from "./errors.js";
4
- export function createRecordGeneration(clientId, ontologyId, idempotencyKey) {
4
+ export function createRecordGeneration(clientId, ontologyId, idempotencyKey, objects) {
5
5
  return Effect.gen(function* () {
6
6
  const api = yield* PrismantixApiClient;
7
- return yield* api.createRecordGeneration(clientId, ontologyId, idempotencyKey);
7
+ return yield* api.createRecordGeneration(clientId, ontologyId, idempotencyKey, objects);
8
8
  });
9
9
  }
10
10
  export function getRecordGeneration(operationId) {
@@ -56,10 +56,23 @@ function requireCompletedGeneration(status) {
56
56
  if (status.status === "canceled") {
57
57
  throw new CliUserError("record_generation_canceled", `Record generation ${status.operationId} was canceled.`);
58
58
  }
59
+ throw new CliUserError("record_generation_failed", failedGenerationMessage(status));
60
+ }
61
+ function failedGenerationStepDetails(status) {
62
+ return status.steps
63
+ .filter((step) => step.state === "failed" || step.persistedCount !== step.requestedCount)
64
+ .map((step) => {
65
+ const issues = step.issues.length > 0 ? `; ${step.issues.join("; ")}` : "";
66
+ return `${step.objectSlug} persisted ${step.persistedCount}/${step.requestedCount}, rejected ${step.rejectedCount}${issues}`;
67
+ });
68
+ }
69
+ function failedGenerationMessage(status) {
59
70
  const failureDetails = status.failure
60
71
  ? `${status.failure.message} (${status.failure.code})`
61
72
  : "The API did not provide failure details.";
62
- throw new CliUserError("record_generation_failed", `Record generation ${status.operationId} failed: ${failureDetails}`);
73
+ const stepDetails = failedGenerationStepDetails(status);
74
+ const failedObjects = stepDetails.length > 0 ? ` Failed objects: ${stepDetails.join(" | ")}.` : "";
75
+ return `Record generation ${status.operationId} failed: ${failureDetails}${failedObjects}`;
63
76
  }
64
77
  function throwIfTimedOut(operationId, elapsedMs, timeoutMs) {
65
78
  if (elapsedMs < timeoutMs)
@@ -82,6 +82,42 @@
82
82
  "list.js"
83
83
  ]
84
84
  },
85
+ "ontology:list": {
86
+ "aliases": [],
87
+ "args": {},
88
+ "description": "List every registered PrismantiX ontology.",
89
+ "flags": {
90
+ "api-base": {
91
+ "description": "PrismantiX API base URL.",
92
+ "env": "PRISMANTIX_API_BASE",
93
+ "name": "api-base",
94
+ "hasDynamicHelp": false,
95
+ "multiple": false,
96
+ "type": "option"
97
+ },
98
+ "json": {
99
+ "description": "Print one machine-readable JSON result to stdout.",
100
+ "name": "json",
101
+ "allowNo": false,
102
+ "type": "boolean"
103
+ }
104
+ },
105
+ "hasDynamicHelp": false,
106
+ "hiddenAliases": [],
107
+ "id": "ontology:list",
108
+ "pluginAlias": "@nyrra/prismantix-cli",
109
+ "pluginName": "@nyrra/prismantix-cli",
110
+ "pluginType": "core",
111
+ "strict": true,
112
+ "enableJsonFlag": false,
113
+ "isESM": true,
114
+ "relativePath": [
115
+ "dist",
116
+ "commands",
117
+ "ontology",
118
+ "list.js"
119
+ ]
120
+ },
85
121
  "records:cancel": {
86
122
  "aliases": [],
87
123
  "args": {
@@ -126,7 +162,7 @@
126
162
  "records:generate": {
127
163
  "aliases": [],
128
164
  "args": {},
129
- "description": "Append a complete ontology-sized default record set for a client.",
165
+ "description": "Append generated records for selected ontology objects, or the complete ontology by default.",
130
166
  "flags": {
131
167
  "api-base": {
132
168
  "description": "PrismantiX API base URL.",
@@ -158,6 +194,20 @@
158
194
  "multiple": false,
159
195
  "type": "option"
160
196
  },
197
+ "object": {
198
+ "description": "Ontology object slug to generate; repeat for multiple objects.",
199
+ "name": "object",
200
+ "hasDynamicHelp": false,
201
+ "multiple": true,
202
+ "type": "option"
203
+ },
204
+ "count": {
205
+ "description": "Records per selected object (1-100; requires --object).",
206
+ "name": "count",
207
+ "hasDynamicHelp": false,
208
+ "multiple": false,
209
+ "type": "option"
210
+ },
161
211
  "poll-interval": {
162
212
  "description": "Polling interval in milliseconds.",
163
213
  "name": "poll-interval",
@@ -311,43 +361,7 @@
311
361
  "records",
312
362
  "status.js"
313
363
  ]
314
- },
315
- "ontology:list": {
316
- "aliases": [],
317
- "args": {},
318
- "description": "List every registered PrismantiX ontology.",
319
- "flags": {
320
- "api-base": {
321
- "description": "PrismantiX API base URL.",
322
- "env": "PRISMANTIX_API_BASE",
323
- "name": "api-base",
324
- "hasDynamicHelp": false,
325
- "multiple": false,
326
- "type": "option"
327
- },
328
- "json": {
329
- "description": "Print one machine-readable JSON result to stdout.",
330
- "name": "json",
331
- "allowNo": false,
332
- "type": "boolean"
333
- }
334
- },
335
- "hasDynamicHelp": false,
336
- "hiddenAliases": [],
337
- "id": "ontology:list",
338
- "pluginAlias": "@nyrra/prismantix-cli",
339
- "pluginName": "@nyrra/prismantix-cli",
340
- "pluginType": "core",
341
- "strict": true,
342
- "enableJsonFlag": false,
343
- "isESM": true,
344
- "relativePath": [
345
- "dist",
346
- "commands",
347
- "ontology",
348
- "list.js"
349
- ]
350
364
  }
351
365
  },
352
- "version": "0.0.3-next.3"
366
+ "version": "0.0.3-next.31"
353
367
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nyrra/prismantix-cli",
3
3
  "description": "PrismantiX API client CLI.",
4
- "version": "0.0.3-next.3",
4
+ "version": "0.0.3-next.31",
5
5
  "author": "NYRRA Inc.",
6
6
  "bin": {
7
7
  "prismantix": "bin/run.js"
@@ -13,7 +13,7 @@
13
13
  "@oclif/core": "^4.11.14",
14
14
  "@oclif/plugin-help": "^6.2.53",
15
15
  "@oclif/plugin-plugins": "5.4.86",
16
- "effect": "4.0.0-beta.106"
16
+ "effect": "4.0.0-rc.116"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@oclif/test": "^4.1.20",