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

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 (67) hide show
  1. package/build/access-rules/index.d.ts +1 -1
  2. package/build/access-tokens/index.d.ts +1 -1
  3. package/build/access-tokens/types.d.ts +2 -0
  4. package/build/access-tokens/types.js +2 -0
  5. package/build/apps/index.d.ts +1 -8
  6. package/build/apps/index.js +0 -9
  7. package/build/attributes/index.d.ts +1 -1
  8. package/build/authentication/index.d.ts +1 -1
  9. package/build/collaboration-policy/core/filter-builder.js +1 -7
  10. package/build/collaboration-policy/core/sql-builder.js +9 -11
  11. package/build/collaboration-policy/core/types.d.ts +10 -81
  12. package/build/collaboration-policy/index.d.ts +4 -5
  13. package/build/collaboration-policy/index.js +3 -4
  14. package/build/collaboration-policy/types/collaboration-policy.d.ts +1370 -0
  15. package/build/collaboration-policy/types/collaboration-policy.js +274 -0
  16. package/build/collaboration-policy/types/index.d.ts +2 -0
  17. package/build/collaboration-policy/types/index.js +1 -0
  18. package/build/collaboration-policy/useCollaborationPolicy.d.ts +4 -13
  19. package/build/collaboration-policy/useCollaborationPolicy.js +1 -23
  20. package/build/collaboration-policy/utils/path-helpers.d.ts +3 -7
  21. package/build/collaboration-policy/utils/path-helpers.js +22 -6
  22. package/build/company-info/index.d.ts +1 -1
  23. package/build/connections/index.d.ts +1 -1
  24. package/build/contracts/index.d.ts +1 -1
  25. package/build/data-planes/types.d.ts +1 -1
  26. package/build/data-streams/index.d.ts +1 -1
  27. package/build/datasets/index.d.ts +12 -12
  28. package/build/datasets/index.js +18 -13
  29. package/build/datasets/statistics-types.d.ts +81 -0
  30. package/build/datasets/types.d.ts +60 -13
  31. package/build/datasets/types.js +1 -0
  32. package/build/forecast/index.d.ts +1 -1
  33. package/build/index.d.ts +1 -0
  34. package/build/index.js +1 -0
  35. package/build/installations/index.d.ts +1 -1
  36. package/build/jobs/index.d.ts +1 -1
  37. package/build/jobs/types.d.ts +1 -0
  38. package/build/mappings/index.d.ts +1 -1
  39. package/build/model-inference/index.d.ts +1 -1
  40. package/build/model-training/index.d.ts +1 -1
  41. package/build/models/index.d.ts +1 -1
  42. package/build/nql/Ast.d.ts +1 -1
  43. package/build/nql/index.d.ts +1 -1
  44. package/build/nql/index.js +1 -1
  45. package/build/products/index.d.ts +1 -1
  46. package/build/queries/index.d.ts +1 -1
  47. package/build/resources/index.d.ts +1 -1
  48. package/build/rosetta/types.d.ts +1 -1
  49. package/build/rosetta/types.js +1 -1
  50. package/build/rosetta-stone/index.d.ts +1 -1
  51. package/build/subscriptions/index.d.ts +1 -1
  52. package/build/uploads/index.d.ts +1 -1
  53. package/build/views/index.d.ts +1 -1
  54. package/build/workflows/index.d.ts +1 -1
  55. package/package.json +10 -11
  56. package/build/collaboration-policy/core/jsonschema/json-schema-types.d.ts +0 -45
  57. package/build/collaboration-policy/core/jsonschema/policy-branches.d.ts +0 -49
  58. package/build/collaboration-policy/core/jsonschema/policy-branches.js +0 -1
  59. package/build/collaboration-policy/core/jsonschema/policy-evaluator.d.ts +0 -22
  60. package/build/collaboration-policy/core/jsonschema/policy-evaluator.js +0 -260
  61. package/build/collaboration-policy/core/jsonschema/sql-builder.d.ts +0 -79
  62. package/build/collaboration-policy/core/jsonschema/sql-builder.js +0 -305
  63. package/build/collaboration-policy/core/jsonschema/sql-poc.d.ts +0 -79
  64. package/build/collaboration-policy/core/jsonschema/sql-poc.js +0 -305
  65. package/build/nql/SubstraitParser.d.ts +0 -771
  66. package/build/nql/SubstraitParser.js +0 -797
  67. /package/build/{collaboration-policy/core/jsonschema/json-schema-types.js → datasets/statistics-types.js} +0 -0
@@ -129,4 +129,4 @@ declare class AccessRulesApi extends BaseApi {
129
129
  */
130
130
  updateccessRuleV2(accessRuleId: number, request: UpdateAccessRuleV2Request): Promise<AccessRuleV2>;
131
131
  }
132
- export { AccessRulesApi, type AccessRule, type AccessRuleV2, type OwnedAccessRule, type SharedAccessRule, type GetAccessRulesParameters, type CreateAccessRuleV2Request, type UpdateAccessRuleV2Request, };
132
+ export { type AccessRule, AccessRulesApi, type AccessRuleV2, type CreateAccessRuleV2Request, type GetAccessRulesParameters, type OwnedAccessRule, type SharedAccessRule, type UpdateAccessRuleV2Request, };
@@ -66,4 +66,4 @@ declare class AccessTokensApi extends BaseApi {
66
66
  */
67
67
  deleteAccessToken(id: string): Promise<void>;
68
68
  }
69
- export { AccessTokensApi, type CreateSystemAccessTokenRequest, type CreateSystemAccessTokenResponse, type UpdateSystemAccessTokenRequest, type AccessTokenMetadata, };
69
+ export { type AccessTokenMetadata, AccessTokensApi, type CreateSystemAccessTokenRequest, type CreateSystemAccessTokenResponse, type UpdateSystemAccessTokenRequest, };
@@ -34,7 +34,9 @@ export declare const resources: {
34
34
  readonly subscriptions: "Subscriptions";
35
35
  readonly uploads: "Uploads";
36
36
  readonly usage: "Usage";
37
+ readonly views: "Views";
37
38
  readonly webhooks: "Webhooks";
39
+ readonly workflows: "Workflows";
38
40
  readonly encryption_materials: "Encryption Materials";
39
41
  };
40
42
  export type Resource = keyof typeof resources;
@@ -33,6 +33,8 @@ export const resources = {
33
33
  subscriptions: "Subscriptions",
34
34
  uploads: "Uploads",
35
35
  usage: "Usage",
36
+ views: "Views",
36
37
  webhooks: "Webhooks",
38
+ workflows: "Workflows",
37
39
  encryption_materials: "Encryption Materials",
38
40
  };
@@ -1,5 +1,4 @@
1
1
  import { BaseApi } from "../base-api";
2
- import type { JsonSchemaConnectorPolicy } from "../collaboration-policy/core/jsonschema/json-schema-types";
3
2
  import type { ApiRecords } from "../types";
4
3
  import type { App, Installation } from "./types";
5
4
  /**
@@ -15,11 +14,5 @@ declare class AppsApi extends BaseApi {
15
14
  */
16
15
  getApps(appCategory?: string): Promise<ApiRecords<App>>;
17
16
  getInstalledApps(appCategory?: string): Promise<ApiRecords<Installation>>;
18
- /**
19
- * Get all interfaces for the current user's installed connectors.
20
- * @param {string[]} [tags] - Optional tags to filter interfaces (e.g. ["audience_delivery"]).
21
- * @returns {Promise<ApiRecords<JsonSchemaConnectorPolicy>>} - Promise resolving with the list of interfaces.
22
- */
23
- getInstalledInterfaces(tags?: string[]): Promise<ApiRecords<JsonSchemaConnectorPolicy>>;
24
17
  }
25
- export { type App, type Installation, AppsApi };
18
+ export { type App, AppsApi, type Installation };
@@ -21,14 +21,5 @@ class AppsApi extends BaseApi {
21
21
  const url = `installations${appCategoryQuery}`;
22
22
  return await this.get(url);
23
23
  }
24
- /**
25
- * Get all interfaces for the current user's installed connectors.
26
- * @param {string[]} [tags] - Optional tags to filter interfaces (e.g. ["audience_delivery"]).
27
- * @returns {Promise<ApiRecords<JsonSchemaConnectorPolicy>>} - Promise resolving with the list of interfaces.
28
- */
29
- async getInstalledInterfaces(tags) {
30
- const queryString = this.constructQueryString(tags != null ? { tags } : undefined);
31
- return await this.get(`${resourceName}/installed/interfaces${queryString}`);
32
- }
33
24
  }
34
25
  export { AppsApi };
@@ -48,4 +48,4 @@ declare class AttributeApiV2 extends BaseApi {
48
48
  */
49
49
  createAttribute(data: Attribute): Promise<Attribute>;
50
50
  }
51
- export { AttributeApi, AttributeApiV2, type Attribute, type ShallowAttribute, type RefAttribute, type SubAttribute, type PrimitiveAttribute, type ArrayAttribute, type ObjectAttribute, };
51
+ export { type ArrayAttribute, type Attribute, AttributeApi, AttributeApiV2, type ObjectAttribute, type PrimitiveAttribute, type RefAttribute, type ShallowAttribute, type SubAttribute, };
@@ -60,4 +60,4 @@ declare class AuthenticationApi extends BaseApi {
60
60
  */
61
61
  checkRegistrationStatusB2b(statusRequest: RegistrationStatusB2bRequest): Promise<RegistrationStatusResponse>;
62
62
  }
63
- export { type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole, type RegistrationStatus, type RegistrationStatusB2bRequest, type RegistrationStatusRequest, type RegistrationStatusResponse, AuthenticationApi, };
63
+ export { type ApiToken, AuthenticationApi, type LoggedInUser, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type RegistrationStatus, type RegistrationStatusB2bRequest, type RegistrationStatusRequest, type RegistrationStatusResponse, type StytchToken, type UserRole, };
@@ -1,12 +1,6 @@
1
1
  import { normalizePathValue } from "../utils/path-helpers";
2
2
  import { resolveAttributeExpression } from "../utils/sql-helpers";
3
- function isAttributeReference(node) {
4
- return (!!node &&
5
- typeof node === "object" &&
6
- "type" in node &&
7
- node.type === "attribute" &&
8
- "attribute_name" in node);
9
- }
3
+ import { isAttributeReference } from "./filter-utils";
10
4
  export function filterToSql(filter, attributeByName, datasetName) {
11
5
  const op = filter.op.toLowerCase();
12
6
  switch (op) {
@@ -41,34 +41,30 @@ function parseDurationToMilliseconds(duration) {
41
41
  * The smallest duration means the most frequent refresh rate.
42
42
  *
43
43
  * @param schedules - Array of ISO 8601 duration strings
44
- * @returns The smallest duration as an ISO 8601 string, or "P1M" (1 month) if no schedules provided
44
+ * @returns The smallest duration in milliseconds, or 2592000000 (30 days/1 month) if no schedules provided
45
45
  */
46
46
  function getSmallestRefreshSchedule(schedules) {
47
- // Default to monthly
48
- const defaultMonthly = "P1M";
47
+ // Default to monthly (30 days in milliseconds)
48
+ const defaultMonthlyMs = 30 * 24 * 60 * 60 * 1000;
49
49
  if (schedules.length === 0) {
50
- return defaultMonthly;
50
+ return defaultMonthlyMs;
51
51
  }
52
52
  if (schedules.length === 1) {
53
53
  try {
54
- // Validate by parsing, but return the original string
55
- parseDurationToMilliseconds(schedules[0]);
56
- return schedules[0];
54
+ return parseDurationToMilliseconds(schedules[0]);
57
55
  }
58
56
  catch (error) {
59
57
  console.warn(`Invalid refresh schedule: ${schedules[0]}, using default`, error);
60
- return defaultMonthly;
58
+ return defaultMonthlyMs;
61
59
  }
62
60
  }
63
61
  // Find the schedule with the smallest duration (most frequent refresh)
64
62
  let smallestValue = Number.MAX_SAFE_INTEGER;
65
- let smallestSchedule = null;
66
63
  for (const schedule of schedules) {
67
64
  try {
68
65
  const value = parseDurationToMilliseconds(schedule);
69
66
  if (value < smallestValue) {
70
67
  smallestValue = value;
71
- smallestSchedule = schedule;
72
68
  }
73
69
  }
74
70
  catch (error) {
@@ -77,7 +73,9 @@ function getSmallestRefreshSchedule(schedules) {
77
73
  }
78
74
  }
79
75
  // If all schedules failed to parse, return default
80
- return smallestSchedule ?? defaultMonthly;
76
+ return smallestValue === Number.MAX_SAFE_INTEGER
77
+ ? defaultMonthlyMs
78
+ : smallestValue;
81
79
  }
82
80
  /**
83
81
  * Builds structured WHERE clauses for a single branch node
@@ -1,91 +1,20 @@
1
- /**
2
- * PathValue describes a path to a subfield, expressed as either dot notation
3
- * or a JSON Pointer. Used in filter attribute references to specify which
4
- * subfield of an attribute to operate on.
5
- */
6
- export type PathValue = {
7
- dot: string;
8
- } | {
9
- pointer: string;
10
- };
11
- /**
12
- * An attribute reference within a filter expression.
13
- */
14
- export interface FilterAttributeRef {
15
- type: "attribute";
16
- attribute_name: string;
17
- path?: PathValue;
18
- }
19
- /**
20
- * A filter expression: a literal value or an attribute reference.
21
- */
22
- export type FilterExpression = string | number | boolean | FilterAttributeRef;
23
- /**
24
- * PolicyFilter is a single filter entry in a policy definition.
25
- *
26
- * This is the canonical filter type used across the codebase (JSON-Schema
27
- * filters, SQL builder, etc.).
28
- */
29
- export type PolicyFilter = PolicyFilterAndOr | PolicyFilterNot | PolicyFilterIsNull | PolicyFilterIn | PolicyFilterCompare | PolicyFilterBetween;
30
- interface PolicyFilterBase {
31
- stage?: "generation";
32
- name?: string;
33
- required?: boolean;
34
- }
35
- interface PolicyFilterAndOr extends PolicyFilterBase {
36
- op: "and" | "or";
37
- args: FilterExpression[];
38
- }
39
- interface PolicyFilterNot extends PolicyFilterBase {
40
- op: "not";
41
- args: FilterExpression[];
42
- }
43
- interface PolicyFilterIsNull extends PolicyFilterBase {
44
- op: "is_null" | "is_not_null";
45
- left: FilterExpression;
46
- }
47
- interface PolicyFilterIn extends PolicyFilterBase {
48
- op: "in" | "not in";
49
- left: FilterExpression;
50
- right: FilterExpression[];
51
- }
52
- interface PolicyFilterCompare extends PolicyFilterBase {
53
- op: "=" | "<>" | ">" | ">=" | "<" | "<=" | "like" | "not like";
54
- left: FilterExpression;
55
- right: FilterExpression;
56
- }
57
- interface PolicyFilterBetween extends PolicyFilterBase {
58
- op: "between";
59
- operand: FilterExpression;
60
- lower: FilterExpression;
61
- upper: FilterExpression;
62
- }
63
- /**
64
- * Map from attribute name -> set of normalized paths that must be selected
65
- * for SQL generation.
66
- */
1
+ import type { CollaborationPolicyType } from "../types";
2
+ type PolicyDefinition = CollaborationPolicyType["policy"]["definition"];
3
+ export type StructureNode = PolicyDefinition["structure"];
4
+ export type ExtendedAttributeNode = Extract<StructureNode, {
5
+ field: unknown;
6
+ }>;
7
+ export type PolicyFilter = NonNullable<PolicyDefinition["filters"]>[number];
8
+ export type PathValue = NonNullable<ExtendedAttributeNode["field"]["additional_required_properties"]>[number];
67
9
  export type AttributePathIndex = Map<string, Set<string>>;
68
- /**
69
- * A logical group of SQL fragments combined by an operation.
70
- */
71
10
  export interface PolicySqlGroup {
72
11
  fragments: Array<string | PolicySqlGroup>;
73
12
  operation: "AND" | "OR";
74
13
  }
75
- /**
76
- * Core SQL fragments required to represent a set of collaboration policies.
77
- */
78
14
  export interface PolicySqlFragments {
79
15
  select: string[];
80
16
  where: Array<PolicySqlGroup | string>;
81
17
  }
82
- /**
83
- * Full result of applying collaboration policies to a dataset, including:
84
- * - which policies were applied
85
- * - which were skipped and why
86
- * - warnings
87
- * - the minimum refresh schedule across applied policies
88
- */
89
18
  export interface PolicyMatchResult extends PolicySqlFragments {
90
19
  appliedPolicies: string[];
91
20
  skippedPolicies: Array<{
@@ -94,7 +23,7 @@ export interface PolicyMatchResult extends PolicySqlFragments {
94
23
  details: string[];
95
24
  }>;
96
25
  warnings: string[];
97
- /** The minimum refresh schedule as an ISO 8601 duration string across all evaluated policies */
98
- refresh_schedule: string;
26
+ /** The minimum refresh schedule in milliseconds across all evaluated policies */
27
+ refresh_schedule: number;
99
28
  }
100
29
  export {};
@@ -1,5 +1,4 @@
1
- export type { JsonSchemaConnectorPolicy } from "./core/jsonschema/json-schema-types";
2
- export { evaluateJsonSchemaPolicies } from "./core/jsonschema/policy-evaluator";
3
- export { buildPolicySql, buildPolicySqlWithJsonSchema, buildPolicySqlWithValidation, categorizePolicies, type JsonSchemaPolicyMatchResult, } from "./core/jsonschema/sql-builder";
4
- export type { AttributePathIndex, FilterAttributeRef, FilterExpression, PathValue, PolicyFilter, PolicyMatchResult, PolicySqlFragments, PolicySqlGroup, } from "./core/types";
5
- export { default as useCollaborationPolicy } from "./useCollaborationPolicy";
1
+ export { buildPolicySql, buildPolicySqlWithValidation, categorizePolicies, } from "./core/sql-builder";
2
+ export type { AttributePathIndex, ExtendedAttributeNode, PathValue, PolicyFilter, PolicyMatchResult, PolicySqlFragments, PolicySqlGroup, StructureNode, } from "./core/types";
3
+ export type { CollaborationPolicyInput, CollaborationPolicyType, } from "./types";
4
+ export { buildCollaborationPolicyJsonSchema, CollaborationPolicy, } from "./types";
@@ -1,4 +1,3 @@
1
- export { evaluateJsonSchemaPolicies } from "./core/jsonschema/policy-evaluator";
2
- export { buildPolicySql, buildPolicySqlWithJsonSchema, buildPolicySqlWithValidation, categorizePolicies, } from "./core/jsonschema/sql-builder";
3
- // Hook-style entrypoint
4
- export { default as useCollaborationPolicy } from "./useCollaborationPolicy";
1
+ // Export the main functions
2
+ export { buildPolicySql, buildPolicySqlWithValidation, categorizePolicies, } from "./core/sql-builder";
3
+ export { buildCollaborationPolicyJsonSchema, CollaborationPolicy, } from "./types";