@centrali-io/centrali-sdk 5.5.0 → 6.0.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.
- package/README.md +164 -14
- package/dist/index.d.ts +1807 -878
- package/dist/index.js +9153 -4076
- package/index.ts +61 -7152
- package/package.json +10 -3
- package/query-types.ts +83 -2
- package/scripts/smoke-types.ts +145 -5
- package/src/client.ts +1507 -0
- package/src/internal/auth.ts +35 -0
- package/src/internal/deprecation.ts +11 -0
- package/src/internal/error.ts +90 -0
- package/src/internal/paths.ts +456 -0
- package/src/internal/queryGuard.ts +21 -0
- package/src/managers/allowedDomains.ts +90 -0
- package/src/managers/anomalyInsights.ts +215 -0
- package/src/managers/auditLog.ts +105 -0
- package/src/managers/collections.ts +197 -0
- package/src/managers/files.ts +182 -0
- package/src/managers/functionRuns.ts +229 -0
- package/src/managers/functions.ts +171 -0
- package/src/managers/orchestrationRuns.ts +122 -0
- package/src/managers/orchestrations.ts +297 -0
- package/src/managers/query.ts +199 -0
- package/src/managers/records.ts +186 -0
- package/src/managers/smartQueries.ts +374 -0
- package/src/managers/structures.ts +205 -0
- package/src/managers/triggers.ts +349 -0
- package/src/managers/validation.ts +303 -0
- package/src/managers/webhookSubscriptions.ts +206 -0
- package/src/realtime/manager.ts +292 -0
- package/src/types/allowedDomains.ts +29 -0
- package/src/types/auth.ts +83 -0
- package/src/types/common.ts +57 -0
- package/src/types/compute.ts +145 -0
- package/src/types/insights.ts +113 -0
- package/src/types/orchestrations.ts +460 -0
- package/src/types/realtime.ts +403 -0
- package/src/types/records.ts +261 -0
- package/src/types/search.ts +44 -0
- package/src/types/smartQueries.ts +303 -0
- package/src/types/structures.ts +203 -0
- package/src/types/triggers.ts +122 -0
- package/src/types/validation.ts +167 -0
- package/src/types/webhooks.ts +114 -0
- package/src/urls.ts +33 -0
- package/dist/query-types.d.ts +0 -187
- package/dist/query-types.js +0 -137
- package/dist/scripts/smoke-types.d.ts +0 -12
- package/dist/scripts/smoke-types.js +0 -102
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// =====================================================
|
|
2
|
+
// Validation Types (Data Quality)
|
|
3
|
+
// =====================================================
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Validation issue types.
|
|
7
|
+
* - 'type': Schema type mismatch (e.g., string where array expected) - rule-based
|
|
8
|
+
* - 'format': Format validation (email, phone, url patterns) - rule-based
|
|
9
|
+
* - 'typo': Spelling/typo detection - AI-based
|
|
10
|
+
* - 'duplicate': Duplicate record detection - rule-based
|
|
11
|
+
* - 'semantic': Logical/semantic issues - AI-based
|
|
12
|
+
*/
|
|
13
|
+
export type ValidationIssueType = 'type' | 'format' | 'typo' | 'duplicate' | 'semantic';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Validation suggestion status.
|
|
17
|
+
*/
|
|
18
|
+
export type ValidationSuggestionStatus = 'pending' | 'accepted' | 'rejected' | 'auto-applied';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A validation suggestion from the AI validation system.
|
|
22
|
+
*/
|
|
23
|
+
export interface ValidationSuggestion {
|
|
24
|
+
/** Unique identifier */
|
|
25
|
+
id: string;
|
|
26
|
+
/** Workspace slug */
|
|
27
|
+
workspaceSlug: string;
|
|
28
|
+
/** Structure ID */
|
|
29
|
+
structureId: string;
|
|
30
|
+
/** Record ID */
|
|
31
|
+
recordId: string;
|
|
32
|
+
/** Structure's record slug */
|
|
33
|
+
recordSlug: string;
|
|
34
|
+
/** Field name with the issue */
|
|
35
|
+
field: string;
|
|
36
|
+
/** Type of issue detected */
|
|
37
|
+
issueType: ValidationIssueType;
|
|
38
|
+
/** Original value in the field */
|
|
39
|
+
originalValue: string | null;
|
|
40
|
+
/** Suggested corrected value */
|
|
41
|
+
suggestedValue: string | null;
|
|
42
|
+
/** Confidence score 0-1 */
|
|
43
|
+
confidence: number;
|
|
44
|
+
/** Current status */
|
|
45
|
+
status: ValidationSuggestionStatus;
|
|
46
|
+
/** Batch ID if created during batch scan */
|
|
47
|
+
batchId: string | null;
|
|
48
|
+
/** Additional metadata */
|
|
49
|
+
metadata: Record<string, any>;
|
|
50
|
+
/** Creation timestamp */
|
|
51
|
+
createdAt: string;
|
|
52
|
+
/** Last update timestamp */
|
|
53
|
+
updatedAt: string;
|
|
54
|
+
/** When resolved (accepted/rejected) */
|
|
55
|
+
resolvedAt: string | null;
|
|
56
|
+
/** Who resolved */
|
|
57
|
+
resolvedBy: string | null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Options for listing validation suggestions.
|
|
62
|
+
*/
|
|
63
|
+
export interface ListValidationSuggestionsOptions {
|
|
64
|
+
/** Filter by structure slug (recordSlug) */
|
|
65
|
+
structureSlug?: string;
|
|
66
|
+
/** Filter by record ID */
|
|
67
|
+
recordId?: string;
|
|
68
|
+
/** Filter by status */
|
|
69
|
+
status?: ValidationSuggestionStatus;
|
|
70
|
+
/** Filter by issue type */
|
|
71
|
+
issueType?: ValidationIssueType;
|
|
72
|
+
/** Filter by batch ID */
|
|
73
|
+
batchId?: string;
|
|
74
|
+
/** Minimum confidence threshold */
|
|
75
|
+
minConfidence?: number;
|
|
76
|
+
/** Maximum results (default: 50, max: 100) */
|
|
77
|
+
limit?: number;
|
|
78
|
+
/** Offset for pagination */
|
|
79
|
+
offset?: number;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Batch scan status.
|
|
84
|
+
*/
|
|
85
|
+
export type BatchScanStatus = 'queued' | 'pending' | 'processing' | 'completed' | 'failed';
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Result from triggering a batch validation scan.
|
|
89
|
+
*/
|
|
90
|
+
export interface BatchScanResult {
|
|
91
|
+
/** Unique batch identifier */
|
|
92
|
+
batchId: string;
|
|
93
|
+
/** Current status */
|
|
94
|
+
status: BatchScanStatus;
|
|
95
|
+
/** Total records to scan */
|
|
96
|
+
total: number;
|
|
97
|
+
/** Records processed so far */
|
|
98
|
+
processed: number;
|
|
99
|
+
/** Issues found so far */
|
|
100
|
+
issuesFound: number;
|
|
101
|
+
/** When the scan started */
|
|
102
|
+
startedAt: string;
|
|
103
|
+
/** When the scan completed (if finished) */
|
|
104
|
+
completedAt?: string;
|
|
105
|
+
/** Error message if failed */
|
|
106
|
+
error?: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Options for triggering a batch scan.
|
|
111
|
+
*/
|
|
112
|
+
export interface TriggerScanOptions {
|
|
113
|
+
/** Validation types to run (defaults to structure config) */
|
|
114
|
+
validationTypes?: ValidationIssueType[];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Options for waiting for a scan to complete.
|
|
119
|
+
*/
|
|
120
|
+
export interface WaitForScanOptions {
|
|
121
|
+
/** Poll interval in milliseconds (default: 5000) */
|
|
122
|
+
pollInterval?: number;
|
|
123
|
+
/** Timeout in milliseconds (default: 300000 = 5 minutes) */
|
|
124
|
+
timeout?: number;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Summary of validation suggestions.
|
|
129
|
+
*/
|
|
130
|
+
export interface ValidationSummary {
|
|
131
|
+
/** Total suggestions */
|
|
132
|
+
total: number;
|
|
133
|
+
/** Pending suggestions */
|
|
134
|
+
pending: number;
|
|
135
|
+
/** Accepted suggestions */
|
|
136
|
+
accepted: number;
|
|
137
|
+
/** Rejected suggestions */
|
|
138
|
+
rejected: number;
|
|
139
|
+
/** Auto-applied suggestions */
|
|
140
|
+
autoApplied: number;
|
|
141
|
+
/** Breakdown by issue type */
|
|
142
|
+
byIssueType: Record<string, number>;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Result from accepting a suggestion.
|
|
147
|
+
*/
|
|
148
|
+
export interface AcceptSuggestionResult {
|
|
149
|
+
/** The updated suggestion */
|
|
150
|
+
suggestion: ValidationSuggestion;
|
|
151
|
+
/** Whether the record was updated */
|
|
152
|
+
recordUpdated: boolean;
|
|
153
|
+
/** Status message */
|
|
154
|
+
message: string;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Result from bulk operations.
|
|
159
|
+
*/
|
|
160
|
+
export interface BulkOperationResult {
|
|
161
|
+
/** Number of successful operations */
|
|
162
|
+
count: number;
|
|
163
|
+
/** Errors for failed operations */
|
|
164
|
+
errors?: Array<{ id: string; error: string }>;
|
|
165
|
+
/** Status message */
|
|
166
|
+
message: string;
|
|
167
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// =====================================================
|
|
2
|
+
// Webhook Subscription Types
|
|
3
|
+
// =====================================================
|
|
4
|
+
|
|
5
|
+
import type { RecordEventType } from './realtime';
|
|
6
|
+
|
|
7
|
+
export type WebhookDeliveryStatus = 'success' | 'failed' | 'retrying';
|
|
8
|
+
|
|
9
|
+
export interface WebhookSubscription {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
url: string;
|
|
13
|
+
events: RecordEventType[];
|
|
14
|
+
/**
|
|
15
|
+
* Optional list of record slugs to scope the subscription to. When null or
|
|
16
|
+
* empty, the subscription receives events for all collections.
|
|
17
|
+
*/
|
|
18
|
+
recordSlugs?: string[] | null;
|
|
19
|
+
active: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Signing secret (`whsec_` prefix). Returned by `create` and `rotateSecret`;
|
|
22
|
+
* undefined on subsequent reads so it is safe to pass subscriptions around.
|
|
23
|
+
*/
|
|
24
|
+
secret?: string;
|
|
25
|
+
workspaceSlug: string;
|
|
26
|
+
createdAt?: string;
|
|
27
|
+
updatedAt?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Full webhook delivery record including request payload and response body.
|
|
32
|
+
* Returned by `deliveries.get()`.
|
|
33
|
+
*/
|
|
34
|
+
export interface WebhookDelivery {
|
|
35
|
+
id: string;
|
|
36
|
+
webhookSubscriptionId: string;
|
|
37
|
+
workspaceSlug: string;
|
|
38
|
+
event: string;
|
|
39
|
+
attemptCount: number;
|
|
40
|
+
status: WebhookDeliveryStatus;
|
|
41
|
+
lastError?: string | null;
|
|
42
|
+
httpStatus?: number | null;
|
|
43
|
+
lastAttemptAt: string;
|
|
44
|
+
nextAttemptAt?: string | null;
|
|
45
|
+
requestPayload?: any;
|
|
46
|
+
responseBody?: string | null;
|
|
47
|
+
/** Delivery ID the row was replayed from, or null for original deliveries. */
|
|
48
|
+
replayedFrom?: string | null;
|
|
49
|
+
createdAt: string;
|
|
50
|
+
updatedAt: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Trimmed delivery row returned by `deliveries.list()` — omits `requestPayload`
|
|
55
|
+
* and `responseBody`. Fetch individual deliveries with `deliveries.get()` to get
|
|
56
|
+
* the full payload and response body.
|
|
57
|
+
*/
|
|
58
|
+
export type WebhookDeliverySummary = Omit<WebhookDelivery, 'requestPayload' | 'responseBody'>;
|
|
59
|
+
|
|
60
|
+
export interface CreateWebhookSubscriptionInput {
|
|
61
|
+
name: string;
|
|
62
|
+
url: string;
|
|
63
|
+
events: RecordEventType[];
|
|
64
|
+
/** Optional — restrict to a subset of collections. Omit for all collections. */
|
|
65
|
+
recordSlugs?: string[];
|
|
66
|
+
active?: boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface UpdateWebhookSubscriptionInput {
|
|
70
|
+
name?: string;
|
|
71
|
+
url?: string;
|
|
72
|
+
events?: RecordEventType[];
|
|
73
|
+
/**
|
|
74
|
+
* Update the collection scope. Pass an empty array (`[]`) to clear the
|
|
75
|
+
* restriction so the subscription receives events for all collections.
|
|
76
|
+
* Omit the field to leave the scope unchanged.
|
|
77
|
+
*/
|
|
78
|
+
recordSlugs?: string[];
|
|
79
|
+
active?: boolean;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface ListWebhookDeliveriesOptions {
|
|
83
|
+
status?: WebhookDeliveryStatus;
|
|
84
|
+
/** ISO 8601 datetime or Date — include deliveries created at or after this time. */
|
|
85
|
+
since?: string | Date;
|
|
86
|
+
/** ISO 8601 datetime or Date — include deliveries created at or before this time. */
|
|
87
|
+
until?: string | Date;
|
|
88
|
+
limit?: number;
|
|
89
|
+
offset?: number;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Pagination metadata returned alongside `deliveries.list()` rows. The backend
|
|
94
|
+
* surfaces `{ data, meta }` which the SDK normalizer passes through as the
|
|
95
|
+
* `ApiResponse` itself — so `result.data` is the array and `result.meta` is
|
|
96
|
+
* this object.
|
|
97
|
+
*/
|
|
98
|
+
export interface WebhookDeliveriesListMeta {
|
|
99
|
+
total: number;
|
|
100
|
+
limit: number;
|
|
101
|
+
offset: number;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface WebhookReplayResponse {
|
|
105
|
+
deliveryId: string;
|
|
106
|
+
replayedFrom: string | null;
|
|
107
|
+
status: WebhookDeliveryStatus;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface WebhookCancelResponse {
|
|
111
|
+
deliveryId: string;
|
|
112
|
+
status: WebhookDeliveryStatus;
|
|
113
|
+
lastError: string | null;
|
|
114
|
+
}
|
package/src/urls.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate the API URL from the base URL by adding the 'api.' subdomain.
|
|
3
|
+
* E.g., https://centrali.io -> https://api.centrali.io
|
|
4
|
+
*/
|
|
5
|
+
export function getApiUrl(baseUrl: string): string {
|
|
6
|
+
const url = new URL(baseUrl);
|
|
7
|
+
// If already has 'api.' subdomain, return as-is
|
|
8
|
+
if (url.hostname.startsWith('api.')) {
|
|
9
|
+
return `${url.protocol}//${url.hostname}`;
|
|
10
|
+
}
|
|
11
|
+
return `${url.protocol}//api.${url.hostname}`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Generate the auth server URL from the base URL.
|
|
16
|
+
* E.g., https://centrali.io -> https://auth.centrali.io
|
|
17
|
+
*/
|
|
18
|
+
export function getAuthUrl(baseUrl: string): string {
|
|
19
|
+
const url = new URL(baseUrl);
|
|
20
|
+
// Strip 'api.' prefix if present to get root domain
|
|
21
|
+
const hostname = url.hostname.startsWith('api.')
|
|
22
|
+
? url.hostname.slice(4)
|
|
23
|
+
: url.hostname;
|
|
24
|
+
return `${url.protocol}//auth.${hostname}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Generate the realtime service URL from the base URL.
|
|
29
|
+
* E.g., https://centrali.io -> https://api.centrali.io/realtime
|
|
30
|
+
*/
|
|
31
|
+
export function getRealtimeUrl(baseUrl: string): string {
|
|
32
|
+
return `${getApiUrl(baseUrl)}/realtime`;
|
|
33
|
+
}
|
package/dist/query-types.d.ts
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
export type QueryDefinition = {
|
|
2
|
-
/**
|
|
3
|
-
* Logical resource being queried.
|
|
4
|
-
*
|
|
5
|
-
* - For records: the collection (a.k.a. structure) slug — e.g. `"orders"`,
|
|
6
|
-
* `"customers"`. The records executor treats this as the collection slug.
|
|
7
|
-
* - For other queryable resources: the resource type identifier — e.g.
|
|
8
|
-
* `"audit-log"`, `"function-runs"`, `"files"`, `"webhook-deliveries"`.
|
|
9
|
-
*
|
|
10
|
-
* Named `resource` (not `collection`) because "collection" is overloaded in
|
|
11
|
-
* Centrali — it's the renamed records-bucket entity, so `collection: "audit-log"`
|
|
12
|
-
* would read as a category error. `resource` is REST-canonical and reads
|
|
13
|
-
* truthfully across every executor.
|
|
14
|
-
*/
|
|
15
|
-
resource: string;
|
|
16
|
-
where?: WhereExpression;
|
|
17
|
-
text?: TextSearchClause;
|
|
18
|
-
sort?: SortClause[];
|
|
19
|
-
page?: PageClause;
|
|
20
|
-
select?: SelectClause;
|
|
21
|
-
include?: IncludeClause[];
|
|
22
|
-
};
|
|
23
|
-
export type SavedQueryDefinition = {
|
|
24
|
-
name: string;
|
|
25
|
-
description?: string;
|
|
26
|
-
query: QueryDefinition;
|
|
27
|
-
variables?: Record<string, QueryVariableDefinition>;
|
|
28
|
-
};
|
|
29
|
-
export type WhereExpression = FieldConditionMap | {
|
|
30
|
-
and: WhereExpression[];
|
|
31
|
-
} | {
|
|
32
|
-
or: WhereExpression[];
|
|
33
|
-
} | {
|
|
34
|
-
not: WhereExpression;
|
|
35
|
-
};
|
|
36
|
-
export type FieldConditionMap = {
|
|
37
|
-
[field: string]: FieldCondition;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Exactly-one helper: for a record of operator → value-type, produces a union
|
|
41
|
-
* where each variant has exactly one of the keys present and all the others
|
|
42
|
-
* forbidden via `?: never`. This enforces the contract's "exactly one operator
|
|
43
|
-
* per FieldCondition" rule at the type level — `{ eq: 1, ne: 2 }` fails to
|
|
44
|
-
* type-check.
|
|
45
|
-
*/
|
|
46
|
-
type ExactlyOneOperator<T> = {
|
|
47
|
-
[K in keyof T]: {
|
|
48
|
-
[P in K]: T[P];
|
|
49
|
-
} & {
|
|
50
|
-
[P in Exclude<keyof T, K>]?: never;
|
|
51
|
-
};
|
|
52
|
-
}[keyof T];
|
|
53
|
-
type FieldOperatorMap = {
|
|
54
|
-
eq: ScalarValue;
|
|
55
|
-
ne: ScalarValue;
|
|
56
|
-
gt: number | string;
|
|
57
|
-
gte: number | string;
|
|
58
|
-
lt: number | string;
|
|
59
|
-
lte: number | string;
|
|
60
|
-
in: ScalarValue[];
|
|
61
|
-
nin: ScalarValue[];
|
|
62
|
-
contains: string;
|
|
63
|
-
startsWith: string;
|
|
64
|
-
endsWith: string;
|
|
65
|
-
hasAny: ScalarValue[];
|
|
66
|
-
hasAll: ScalarValue[];
|
|
67
|
-
exists: boolean;
|
|
68
|
-
};
|
|
69
|
-
export type FieldCondition = ExactlyOneOperator<FieldOperatorMap>;
|
|
70
|
-
export type ScalarValue = string | number | boolean | null;
|
|
71
|
-
export type CanonicalOperator = 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'nin' | 'contains' | 'startsWith' | 'endsWith' | 'hasAny' | 'hasAll' | 'exists';
|
|
72
|
-
export declare const CANONICAL_OPERATORS: readonly CanonicalOperator[];
|
|
73
|
-
/** Argument shape an operator expects in a `FieldCondition`. */
|
|
74
|
-
export type OperatorValueShape =
|
|
75
|
-
/** Single scalar input (string/number/boolean/null). */
|
|
76
|
-
'scalar'
|
|
77
|
-
/** Array of scalars — UI typically renders a chip / comma input. */
|
|
78
|
-
| 'array'
|
|
79
|
-
/** Boolean toggle — `exists`. */
|
|
80
|
-
| 'boolean';
|
|
81
|
-
/**
|
|
82
|
-
* Logical type families an operator applies to. The visual builder narrows
|
|
83
|
-
* the dropdown to the operators valid for the selected field's type.
|
|
84
|
-
*
|
|
85
|
-
* `any` means the operator is type-agnostic (`eq`, `ne`, `exists`).
|
|
86
|
-
*/
|
|
87
|
-
export type OperatorTypeApplicability = 'string' | 'number' | 'boolean' | 'datetime' | 'array' | 'any';
|
|
88
|
-
export type OperatorMeta = {
|
|
89
|
-
/** Canonical bare operator name. */
|
|
90
|
-
operator: CanonicalOperator;
|
|
91
|
-
/** Human-readable label for dropdowns. */
|
|
92
|
-
label: string;
|
|
93
|
-
/** Short, symbol-style label suitable for compact number/datetime UIs. */
|
|
94
|
-
shortLabel?: string;
|
|
95
|
-
/** Argument shape — drives the value input affordance. */
|
|
96
|
-
valueShape: OperatorValueShape;
|
|
97
|
-
/** Field types this operator applies to. */
|
|
98
|
-
applicableTypes: OperatorTypeApplicability[];
|
|
99
|
-
};
|
|
100
|
-
export declare const OPERATOR_METADATA: Readonly<Record<CanonicalOperator, OperatorMeta>>;
|
|
101
|
-
/**
|
|
102
|
-
* Operators applicable to a given field-type. Used by builder UIs to narrow
|
|
103
|
-
* the dropdown when the user selects a field; falls back to `any`-applicable
|
|
104
|
-
* operators when the type is unknown.
|
|
105
|
-
*/
|
|
106
|
-
export declare function operatorsForFieldType(type: OperatorTypeApplicability | string): readonly OperatorMeta[];
|
|
107
|
-
export type TextSearchClause = {
|
|
108
|
-
query: string;
|
|
109
|
-
fields?: string[];
|
|
110
|
-
typoTolerance?: boolean;
|
|
111
|
-
};
|
|
112
|
-
export type SortClause = {
|
|
113
|
-
field: string;
|
|
114
|
-
direction: 'asc' | 'desc';
|
|
115
|
-
};
|
|
116
|
-
/**
|
|
117
|
-
* Two pagination modes. Per contract §6 they are mutually exclusive — `cursor`
|
|
118
|
-
* is forbidden in offset mode and `offset` is forbidden in cursor mode so a
|
|
119
|
-
* caller cannot construct an ambiguous request.
|
|
120
|
-
*/
|
|
121
|
-
export type PageClause = {
|
|
122
|
-
limit: number;
|
|
123
|
-
offset?: number;
|
|
124
|
-
cursor?: never;
|
|
125
|
-
} | {
|
|
126
|
-
limit: number;
|
|
127
|
-
cursor?: string;
|
|
128
|
-
offset?: never;
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* Records Phase 1 page defaults (contract §6).
|
|
132
|
-
* Same default and cap for GET adapter and POST query body.
|
|
133
|
-
*/
|
|
134
|
-
export declare const RECORDS_PAGE_DEFAULT_LIMIT = 50;
|
|
135
|
-
export declare const RECORDS_PAGE_MAX_LIMIT = 500;
|
|
136
|
-
export type SelectClause = {
|
|
137
|
-
fields: string[];
|
|
138
|
-
};
|
|
139
|
-
/**
|
|
140
|
-
* Phase 1 reserves the shape but rejects execution with `unsupported_clause`.
|
|
141
|
-
*/
|
|
142
|
-
export type IncludeClause = {
|
|
143
|
-
relation: string;
|
|
144
|
-
};
|
|
145
|
-
export type VariableType = 'string' | 'number' | 'boolean' | 'datetime' | 'id' | {
|
|
146
|
-
array: VariableType;
|
|
147
|
-
} | {
|
|
148
|
-
reference: string;
|
|
149
|
-
};
|
|
150
|
-
export type QueryVariableDefinition = {
|
|
151
|
-
type: VariableType;
|
|
152
|
-
required?: boolean;
|
|
153
|
-
default?: ScalarValue;
|
|
154
|
-
description?: string;
|
|
155
|
-
};
|
|
156
|
-
export type QueryExecutionMode = 'filter' | 'search' | 'hybrid';
|
|
157
|
-
export type QueryResultMeta = {
|
|
158
|
-
total?: number;
|
|
159
|
-
limit: number;
|
|
160
|
-
offset?: number;
|
|
161
|
-
cursor?: string;
|
|
162
|
-
nextCursor?: string;
|
|
163
|
-
hasMore?: boolean;
|
|
164
|
-
processingTimeMs?: number;
|
|
165
|
-
mode?: QueryExecutionMode;
|
|
166
|
-
};
|
|
167
|
-
export type QueryResult<T> = {
|
|
168
|
-
data: T[];
|
|
169
|
-
meta: QueryResultMeta;
|
|
170
|
-
};
|
|
171
|
-
export type QueryErrorCode = 'unsupported_clause' | 'unsupported_operator' | 'unsupported_legacy_operator' | 'unreadable_field' | 'invalid_query' | 'legacy_write_unsupported';
|
|
172
|
-
export type QueryError = {
|
|
173
|
-
code: QueryErrorCode;
|
|
174
|
-
message: string;
|
|
175
|
-
/** Dotted path inside the QueryDefinition where the error was detected, e.g. "where.data.status.eq". */
|
|
176
|
-
path?: string;
|
|
177
|
-
/** For `unsupported_clause` / `unsupported_operator`, the offending name. */
|
|
178
|
-
clause?: string;
|
|
179
|
-
};
|
|
180
|
-
export type ValidationResult<T> = {
|
|
181
|
-
ok: true;
|
|
182
|
-
value: T;
|
|
183
|
-
} | {
|
|
184
|
-
ok: false;
|
|
185
|
-
errors: QueryError[];
|
|
186
|
-
};
|
|
187
|
-
export {};
|
package/dist/query-types.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// ---------------------------------------------------------------------------
|
|
3
|
-
// AUTO-GENERATED — DO NOT EDIT BY HAND.
|
|
4
|
-
//
|
|
5
|
-
// Source: services/backend/shared/query/src/types.ts (@centrali/query)
|
|
6
|
-
// Regenerate: `npm run sync:query-types` (also runs on prebuild).
|
|
7
|
-
//
|
|
8
|
-
// The shared package is the single source of truth for canonical query types.
|
|
9
|
-
// This file is a types-only port so the published SDK stays a single npm
|
|
10
|
-
// install. See CEN-1194 for the alignment, CEN-1202 for runtime bundling.
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.RECORDS_PAGE_MAX_LIMIT = exports.RECORDS_PAGE_DEFAULT_LIMIT = exports.OPERATOR_METADATA = exports.CANONICAL_OPERATORS = void 0;
|
|
14
|
-
exports.operatorsForFieldType = operatorsForFieldType;
|
|
15
|
-
exports.CANONICAL_OPERATORS = [
|
|
16
|
-
'eq',
|
|
17
|
-
'ne',
|
|
18
|
-
'gt',
|
|
19
|
-
'gte',
|
|
20
|
-
'lt',
|
|
21
|
-
'lte',
|
|
22
|
-
'in',
|
|
23
|
-
'nin',
|
|
24
|
-
'contains',
|
|
25
|
-
'startsWith',
|
|
26
|
-
'endsWith',
|
|
27
|
-
'hasAny',
|
|
28
|
-
'hasAll',
|
|
29
|
-
'exists',
|
|
30
|
-
];
|
|
31
|
-
exports.OPERATOR_METADATA = {
|
|
32
|
-
eq: {
|
|
33
|
-
operator: 'eq',
|
|
34
|
-
label: 'equals',
|
|
35
|
-
shortLabel: '=',
|
|
36
|
-
valueShape: 'scalar',
|
|
37
|
-
applicableTypes: ['any'],
|
|
38
|
-
},
|
|
39
|
-
ne: {
|
|
40
|
-
operator: 'ne',
|
|
41
|
-
label: 'not equals',
|
|
42
|
-
shortLabel: '≠',
|
|
43
|
-
valueShape: 'scalar',
|
|
44
|
-
applicableTypes: ['any'],
|
|
45
|
-
},
|
|
46
|
-
gt: {
|
|
47
|
-
operator: 'gt',
|
|
48
|
-
label: 'greater than',
|
|
49
|
-
shortLabel: '>',
|
|
50
|
-
valueShape: 'scalar',
|
|
51
|
-
applicableTypes: ['number', 'datetime'],
|
|
52
|
-
},
|
|
53
|
-
gte: {
|
|
54
|
-
operator: 'gte',
|
|
55
|
-
label: 'greater or equal',
|
|
56
|
-
shortLabel: '≥',
|
|
57
|
-
valueShape: 'scalar',
|
|
58
|
-
applicableTypes: ['number', 'datetime'],
|
|
59
|
-
},
|
|
60
|
-
lt: {
|
|
61
|
-
operator: 'lt',
|
|
62
|
-
label: 'less than',
|
|
63
|
-
shortLabel: '<',
|
|
64
|
-
valueShape: 'scalar',
|
|
65
|
-
applicableTypes: ['number', 'datetime'],
|
|
66
|
-
},
|
|
67
|
-
lte: {
|
|
68
|
-
operator: 'lte',
|
|
69
|
-
label: 'less or equal',
|
|
70
|
-
shortLabel: '≤',
|
|
71
|
-
valueShape: 'scalar',
|
|
72
|
-
applicableTypes: ['number', 'datetime'],
|
|
73
|
-
},
|
|
74
|
-
in: {
|
|
75
|
-
operator: 'in',
|
|
76
|
-
label: 'in',
|
|
77
|
-
valueShape: 'array',
|
|
78
|
-
applicableTypes: ['string', 'number', 'datetime'],
|
|
79
|
-
},
|
|
80
|
-
nin: {
|
|
81
|
-
operator: 'nin',
|
|
82
|
-
label: 'not in',
|
|
83
|
-
valueShape: 'array',
|
|
84
|
-
applicableTypes: ['string', 'number', 'datetime'],
|
|
85
|
-
},
|
|
86
|
-
contains: {
|
|
87
|
-
operator: 'contains',
|
|
88
|
-
label: 'contains',
|
|
89
|
-
valueShape: 'scalar',
|
|
90
|
-
applicableTypes: ['string'],
|
|
91
|
-
},
|
|
92
|
-
startsWith: {
|
|
93
|
-
operator: 'startsWith',
|
|
94
|
-
label: 'starts with',
|
|
95
|
-
valueShape: 'scalar',
|
|
96
|
-
applicableTypes: ['string'],
|
|
97
|
-
},
|
|
98
|
-
endsWith: {
|
|
99
|
-
operator: 'endsWith',
|
|
100
|
-
label: 'ends with',
|
|
101
|
-
valueShape: 'scalar',
|
|
102
|
-
applicableTypes: ['string'],
|
|
103
|
-
},
|
|
104
|
-
hasAny: {
|
|
105
|
-
operator: 'hasAny',
|
|
106
|
-
label: 'has any of',
|
|
107
|
-
valueShape: 'array',
|
|
108
|
-
applicableTypes: ['array'],
|
|
109
|
-
},
|
|
110
|
-
hasAll: {
|
|
111
|
-
operator: 'hasAll',
|
|
112
|
-
label: 'has all of',
|
|
113
|
-
valueShape: 'array',
|
|
114
|
-
applicableTypes: ['array'],
|
|
115
|
-
},
|
|
116
|
-
exists: {
|
|
117
|
-
operator: 'exists',
|
|
118
|
-
label: 'exists',
|
|
119
|
-
valueShape: 'boolean',
|
|
120
|
-
applicableTypes: ['any'],
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
/**
|
|
124
|
-
* Operators applicable to a given field-type. Used by builder UIs to narrow
|
|
125
|
-
* the dropdown when the user selects a field; falls back to `any`-applicable
|
|
126
|
-
* operators when the type is unknown.
|
|
127
|
-
*/
|
|
128
|
-
function operatorsForFieldType(type) {
|
|
129
|
-
const t = type;
|
|
130
|
-
return exports.CANONICAL_OPERATORS.map((op) => exports.OPERATOR_METADATA[op]).filter((meta) => meta.applicableTypes.includes('any') || meta.applicableTypes.includes(t));
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Records Phase 1 page defaults (contract §6).
|
|
134
|
-
* Same default and cap for GET adapter and POST query body.
|
|
135
|
-
*/
|
|
136
|
-
exports.RECORDS_PAGE_DEFAULT_LIMIT = 50;
|
|
137
|
-
exports.RECORDS_PAGE_MAX_LIMIT = 500;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type-only smoke for the canonical query surface added in 5.5.0 (CEN-1194).
|
|
3
|
-
*
|
|
4
|
-
* Runs as part of `npm run build` because it lives in the same project as
|
|
5
|
-
* `index.ts`. Compiling means the canonical types and new methods type-check
|
|
6
|
-
* end-to-end. There is no runtime assertion — when the SDK has a real test
|
|
7
|
-
* harness (separate ticket), these calls will turn into integration tests.
|
|
8
|
-
*
|
|
9
|
-
* To run manually:
|
|
10
|
-
* npx tsc --noEmit scripts/smoke-types.ts
|
|
11
|
-
*/
|
|
12
|
-
export {};
|