@seliseblocks/cli-os 0.2.9 → 0.2.10

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.
@@ -26,7 +26,7 @@ export async function dataRulesPull(argv) {
26
26
  query: { schemaName }
27
27
  });
28
28
  for (const item of unwrapDataArray(response, "data access policy")) {
29
- policies.push(toPortablePolicy(item));
29
+ policies.push(toPortablePolicy(item, schemaName));
30
30
  }
31
31
  }
32
32
  const file = await writeRulesFile({ policies });
@@ -15,8 +15,13 @@ export declare function toPortableSchema(raw: Record<string, unknown>): SchemaDo
15
15
  * request DTOs expect `schemaName` -- field names are mapped explicitly rather than
16
16
  * spreading the response, and the source project's `itemId`/`schemaId` are dropped
17
17
  * since they are meaningless in a different destination project.
18
+ *
19
+ * `entityName` has been observed coming back as an empty string against a live
20
+ * project (the backend appears not to populate it), so `fallbackSchemaName` --
21
+ * the name the policy was queried by -- is used whenever the response doesn't
22
+ * supply a usable one.
18
23
  */
19
- export declare function toPortablePolicy(raw: Record<string, unknown>): PortablePolicy;
24
+ export declare function toPortablePolicy(raw: Record<string, unknown>, fallbackSchemaName?: string): PortablePolicy;
20
25
  export declare function readSchemaFiles(): Promise<Array<{
21
26
  file: string;
22
27
  schema: SchemaDocument;
@@ -80,10 +80,17 @@ export function toPortableSchema(raw) {
80
80
  * request DTOs expect `schemaName` -- field names are mapped explicitly rather than
81
81
  * spreading the response, and the source project's `itemId`/`schemaId` are dropped
82
82
  * since they are meaningless in a different destination project.
83
+ *
84
+ * `entityName` has been observed coming back as an empty string against a live
85
+ * project (the backend appears not to populate it), so `fallbackSchemaName` --
86
+ * the name the policy was queried by -- is used whenever the response doesn't
87
+ * supply a usable one.
83
88
  */
84
- export function toPortablePolicy(raw) {
89
+ export function toPortablePolicy(raw, fallbackSchemaName) {
90
+ const entityName = typeof raw.entityName === "string" && raw.entityName ? raw.entityName : undefined;
91
+ const rawSchemaName = typeof raw.schemaName === "string" && raw.schemaName ? raw.schemaName : undefined;
85
92
  const policy = {
86
- schemaName: String(raw.entityName ?? raw.schemaName ?? ""),
93
+ schemaName: entityName ?? rawSchemaName ?? fallbackSchemaName ?? "",
87
94
  policyName: String(raw.policyName ?? "")
88
95
  };
89
96
  if (typeof raw.policyDescription === "string")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seliseblocks/cli-os",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "CLI for SELISE Blocks project setup and configuration.",
5
5
  "license": "MIT",
6
6
  "type": "module",