@narrative.io/data-collaboration-sdk-ts 2.94.1 → 2.95.0-beta.0

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.
Files changed (31) hide show
  1. package/build/apps/index.d.ts +7 -0
  2. package/build/apps/index.js +9 -0
  3. package/build/collaboration-policy/core/filter-builder.js +7 -1
  4. package/build/collaboration-policy/core/jsonschema/json-schema-types.d.ts +45 -0
  5. package/build/collaboration-policy/core/jsonschema/json-schema-types.js +1 -0
  6. package/build/collaboration-policy/core/jsonschema/policy-branches.d.ts +49 -0
  7. package/build/collaboration-policy/core/jsonschema/policy-branches.js +1 -0
  8. package/build/collaboration-policy/core/jsonschema/policy-evaluator.d.ts +22 -0
  9. package/build/collaboration-policy/core/jsonschema/policy-evaluator.js +260 -0
  10. package/build/collaboration-policy/core/jsonschema/sql-builder.d.ts +79 -0
  11. package/build/collaboration-policy/core/jsonschema/sql-builder.js +305 -0
  12. package/build/collaboration-policy/core/jsonschema/sql-poc.d.ts +79 -0
  13. package/build/collaboration-policy/core/jsonschema/sql-poc.js +305 -0
  14. package/build/collaboration-policy/core/sql-builder.js +11 -9
  15. package/build/collaboration-policy/core/types.d.ts +81 -10
  16. package/build/collaboration-policy/index.d.ts +5 -4
  17. package/build/collaboration-policy/index.js +4 -3
  18. package/build/collaboration-policy/useCollaborationPolicy.d.ts +13 -4
  19. package/build/collaboration-policy/useCollaborationPolicy.js +23 -1
  20. package/build/collaboration-policy/utils/path-helpers.d.ts +7 -3
  21. package/build/collaboration-policy/utils/path-helpers.js +6 -22
  22. package/build/datasets/index.d.ts +11 -2
  23. package/build/datasets/index.js +12 -0
  24. package/build/datasets/types.d.ts +4 -0
  25. package/build/nql/SubstraitParser.d.ts +771 -0
  26. package/build/nql/SubstraitParser.js +797 -0
  27. package/package.json +4 -3
  28. package/build/collaboration-policy/types/collaboration-policy.d.ts +0 -1370
  29. package/build/collaboration-policy/types/collaboration-policy.js +0 -274
  30. package/build/collaboration-policy/types/index.d.ts +0 -2
  31. package/build/collaboration-policy/types/index.js +0 -1
@@ -1,274 +0,0 @@
1
- import * as z from "zod/v4";
2
- /** Branded types */
3
- const CollaborationPolicyIdentifier = z
4
- .string()
5
- .regex(/^[a-zA-Z0-9_-]+$/)
6
- .brand("CollaborationPolicyId")
7
- .meta({
8
- id: "collaboration_policy_identifier",
9
- });
10
- /**
11
- * Refresh Schedule Schema
12
- *
13
- * Specifies how often the destination should be refreshed to ensure data doesn't expire.
14
- * This is the maximum time interval allowed between destination updates. Waiting longer
15
- * than this duration may result in the destination expiring data that should be retained.
16
- *
17
- * Uses ISO 8601 duration format (e.g., "PT1H" for 1 hour, "P1D" for 1 day).
18
- * Supported values:
19
- * - PT1H: Hourly (1 hour)
20
- * - P1D: Daily (1 day)
21
- * - P7D: Weekly (7 days)
22
- * - P1M: Monthly (1 month)
23
- * - P0D: Once (no recurring refresh)
24
- * - Custom ISO 8601 duration strings (e.g., "PT30M" for 30 minutes, "P2W" for 2 weeks)
25
- */
26
- const RefreshScheduleSchema = z
27
- .object({
28
- max: z
29
- .string()
30
- .regex(/^P(?!$)(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?$/, "Invalid ISO 8601 duration format. Expected format like 'PT1H' (1 hour), 'P1D' (1 day), 'P7D' (7 days), 'P1M' (1 month), or 'P0D' (once)"),
31
- })
32
- .strict()
33
- .meta({
34
- id: "refresh_schedule",
35
- });
36
- const CollaborationPolicyDefinitionMetadataSchema = z
37
- .object({
38
- tags: z.array(z.string().regex(/^[a-zA-Z0-9_-]+$/)).optional(),
39
- refresh_schedule: RefreshScheduleSchema.optional(),
40
- })
41
- .meta({ id: "metadata" });
42
- const JsonPointerSchema = z
43
- .string()
44
- .regex(/^(#\/|\/).+/, 'JSON Pointer must start with "/" or "#/".')
45
- .meta({ id: "json-pointer" });
46
- /** Path can be dot-style or JSON Pointer */
47
- const PathSchema = z
48
- .union([
49
- z
50
- .object({
51
- dot: z.string().min(1, "Dot path cannot be empty"),
52
- })
53
- .strict(),
54
- z
55
- .object({
56
- pointer: JsonPointerSchema,
57
- })
58
- .strict(),
59
- ])
60
- .meta({ id: "path" });
61
- /** ---------------------------
62
- * Base + contextual variants
63
- * --------------------------*/
64
- /**
65
- * BaseAttributeRef:
66
- * - supports either `attribute_name` (by name) OR `attribute` (by pointer), not both
67
- * - includes both `additional_required_properties` and `path` (context will prune)
68
- */
69
- const BaseAttributeRef = z
70
- .object({
71
- type: z.literal("attribute").meta({ id: "field_type" }),
72
- // Choose ONE of these identifiers:
73
- attribute_name: z.string().meta({ id: "attribute_name" }),
74
- // Context-specific fields (trim in the derived schemas):
75
- additional_required_properties: z
76
- .array(PathSchema)
77
- .optional()
78
- .meta({ id: "additional_required_properties" }),
79
- path: PathSchema.optional(),
80
- })
81
- .strict()
82
- .meta({ id: "attribute_reference" });
83
- /**
84
- * StructureAttributeRef:
85
- * - used in your “structure” (the logical tree)
86
- * - allows: attribute_name + additional_required_properties
87
- * - forbids: path, attribute (pointer)
88
- * Example target:
89
- * field: {
90
- * type: "attribute",
91
- * attribute_name: "sha256_hashed_email",
92
- * additional_required_properties: [{ dot: "type" }],
93
- * }
94
- */
95
- const StructureAttributeRef = BaseAttributeRef.omit({
96
- path: true,
97
- }).meta({ id: "structure_attribute_reference" });
98
- /**
99
- * FilterAttributeRef:
100
- * - used inside filters
101
- * - allows: attribute (pointer) + optional path
102
- * - forbids: additional_required_properties, attribute_name
103
- * Example target:
104
- * left: {
105
- * type: "attribute",
106
- * attribute: "https://api.narrative.io/attributes/iso_3166_1_country",
107
- * path: { dot: "value" },
108
- * }
109
- */
110
- const FilterAttributeRef = BaseAttributeRef.omit({
111
- additional_required_properties: true,
112
- }).meta({ id: "filter_attribute_reference" });
113
- // Now Expression can reference Filter without a lazy;
114
- // the recursive bits inside Filter are handled by getters.
115
- const Expression = z
116
- .union([
117
- z
118
- .string()
119
- .refine((s) => !s.startsWith("https://api.narrative.io/attributes/"), "String expression cannot be a JSON pointer; use { type:'attribute', attribute: ... }"),
120
- z.number(),
121
- z.boolean(),
122
- FilterAttributeRef,
123
- ])
124
- .meta({ id: "expression" });
125
- const FilterAndOr = z
126
- .object({
127
- op: z.enum(["and", "or"]),
128
- stage: z.literal("generation").default("generation"),
129
- name: z.string().optional(),
130
- required: z.boolean().default(true),
131
- get args() {
132
- return z.array(Expression).min(2);
133
- },
134
- })
135
- .strict();
136
- const FilterNot = z
137
- .object({
138
- op: z.literal("not"),
139
- stage: z.literal("generation").default("generation"),
140
- name: z.string().optional(),
141
- required: z.boolean().default(true),
142
- get args() {
143
- return z.array(Expression).length(1);
144
- },
145
- })
146
- .strict();
147
- const FilterIsNull = z
148
- .object({
149
- op: z.enum(["is_null", "is_not_null"]),
150
- stage: z.literal("generation").default("generation"),
151
- name: z.string().optional(),
152
- required: z.boolean().default(true),
153
- get left() {
154
- return Expression;
155
- },
156
- })
157
- .strict();
158
- const FilterIn = z
159
- .object({
160
- op: z.enum(["in", "not in"]),
161
- stage: z.literal("generation").default("generation"),
162
- name: z.string().optional(),
163
- required: z.boolean().default(true),
164
- get left() {
165
- return Expression;
166
- },
167
- get right() {
168
- return z.array(Expression).min(1);
169
- },
170
- })
171
- .strict();
172
- const FilterCompare = z
173
- .object({
174
- op: z.enum(["=", "<>", ">", ">=", "<", "<=", "like", "not like"]),
175
- stage: z.literal("generation").default("generation"),
176
- name: z.string().optional(),
177
- required: z.boolean().default(true),
178
- get left() {
179
- return Expression;
180
- },
181
- get right() {
182
- return Expression;
183
- },
184
- })
185
- .strict();
186
- const FilterBetween = z
187
- .object({
188
- op: z.literal("between"),
189
- stage: z.literal("generation").default("generation"),
190
- name: z.string().optional(),
191
- required: z.boolean().default(true),
192
- get operand() {
193
- return Expression;
194
- },
195
- get lower() {
196
- return Expression;
197
- },
198
- get upper() {
199
- return Expression;
200
- },
201
- })
202
- .strict();
203
- const Filter = z
204
- .union([
205
- FilterAndOr,
206
- FilterNot,
207
- FilterIsNull,
208
- FilterIn,
209
- FilterCompare,
210
- FilterBetween,
211
- ])
212
- .meta({ id: "filter" });
213
- const logicalTree = (leaf) => {
214
- const NodeSchema = z.lazy(() => z
215
- .union([
216
- z
217
- .object({
218
- anyOf: z
219
- .array(z.union([leaf, NodeSchema]))
220
- .min(1)
221
- .meta({ id: "any_of" }),
222
- })
223
- .strict()
224
- .meta({ id: "any_of_object" }),
225
- z
226
- .object({
227
- allOf: z
228
- .array(z.union([leaf, NodeSchema]))
229
- .min(1)
230
- .meta({ id: "all_of" }),
231
- })
232
- .strict()
233
- .meta({ id: "all_of_object" }),
234
- ])
235
- .meta({ id: "logical_node" }));
236
- // Top-level can be a leaf T or a logical node.
237
- return z.union([leaf, NodeSchema]).meta({ id: "logical_tree" });
238
- };
239
- const ExtendedAttribute = z
240
- .object({
241
- field: StructureAttributeRef,
242
- filters: z.array(Filter).optional(),
243
- })
244
- .meta({ id: "extended_attribute" });
245
- const CollaborationPolicyDefinitionShape = z
246
- .object({
247
- id: CollaborationPolicyIdentifier,
248
- structure: logicalTree(ExtendedAttribute).meta({ id: "structure" }),
249
- filters: z.array(Filter).optional(),
250
- })
251
- .meta({ id: "shape" });
252
- const CollaborationPolicyDefinition = z
253
- .object({
254
- metadata: CollaborationPolicyDefinitionMetadataSchema,
255
- definition: CollaborationPolicyDefinitionShape,
256
- })
257
- .meta({ id: "policy_definition" });
258
- const CollaborationPolicy = z
259
- .object({
260
- name: CollaborationPolicyIdentifier,
261
- description: z.string().max(2000).optional(),
262
- display_name: z.string().max(255),
263
- policy: CollaborationPolicyDefinition,
264
- })
265
- .meta({ id: "policy" });
266
- // Export the schema for validation
267
- export { CollaborationPolicy };
268
- export function buildCollaborationPolicyJsonSchema(options = {}) {
269
- const override = (options ?? {});
270
- return z.toJSONSchema(CollaborationPolicy, {
271
- reused: "ref",
272
- ...override,
273
- });
274
- }
@@ -1,2 +0,0 @@
1
- export type { CollaborationPolicyInput, CollaborationPolicyType, } from "./collaboration-policy";
2
- export { buildCollaborationPolicyJsonSchema, CollaborationPolicy, } from "./collaboration-policy";
@@ -1 +0,0 @@
1
- export { buildCollaborationPolicyJsonSchema, CollaborationPolicy, } from "./collaboration-policy";