@sinio/sdk 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +136 -2
- package/dist/cjs/client.d.ts +75 -0
- package/dist/cjs/client.js +196 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/errors.d.ts +35 -0
- package/dist/cjs/errors.js +60 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/http.d.ts +22 -0
- package/dist/cjs/http.js +139 -0
- package/dist/cjs/http.js.map +1 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.js +27 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/serialize.d.ts +49 -0
- package/dist/cjs/serialize.js +191 -0
- package/dist/cjs/serialize.js.map +1 -0
- package/dist/cjs/types.d.ts +126 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/vocabularies.d.ts +23 -0
- package/dist/cjs/vocabularies.js +39 -0
- package/dist/cjs/vocabularies.js.map +1 -0
- package/dist/esm/client.d.ts +75 -0
- package/dist/esm/client.js +192 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/errors.d.ts +35 -0
- package/dist/esm/errors.js +49 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/http.d.ts +22 -0
- package/dist/esm/http.js +134 -0
- package/dist/esm/http.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/serialize.d.ts +49 -0
- package/dist/esm/serialize.js +179 -0
- package/dist/esm/serialize.js.map +1 -0
- package/dist/esm/types.d.ts +126 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/vocabularies.d.ts +23 -0
- package/dist/esm/vocabularies.js +35 -0
- package/dist/esm/vocabularies.js.map +1 -0
- package/package.json +43 -4
package/dist/cjs/http.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Transport = void 0;
|
|
4
|
+
exports.parseRetryAfter = parseRetryAfter;
|
|
5
|
+
const errors_ts_1 = require("./errors.js");
|
|
6
|
+
const defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
7
|
+
/** `Retry-After` is either a delay in seconds or an HTTP date. Both are accepted. */
|
|
8
|
+
function parseRetryAfter(header, now = Date.now()) {
|
|
9
|
+
if (header === null) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
const seconds = Number(header);
|
|
13
|
+
if (Number.isFinite(seconds)) {
|
|
14
|
+
return Math.max(0, seconds);
|
|
15
|
+
}
|
|
16
|
+
const date = Date.parse(header);
|
|
17
|
+
if (Number.isNaN(date)) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return Math.max(0, (date - now) / 1000);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A 429 or a 5xx is retried, and so is a dropped connection: ingestion is
|
|
24
|
+
* idempotent, so a replay can only ever be counted as a duplicate. A 4xx that
|
|
25
|
+
* is not a 429 is the caller's fault and is raised immediately.
|
|
26
|
+
*/
|
|
27
|
+
function isRetriableStatus(status) {
|
|
28
|
+
return status === 429 || status >= 500;
|
|
29
|
+
}
|
|
30
|
+
class Transport {
|
|
31
|
+
options;
|
|
32
|
+
fetchImpl;
|
|
33
|
+
sleep;
|
|
34
|
+
constructor(options) {
|
|
35
|
+
this.options = options;
|
|
36
|
+
const provided = options.fetch ?? globalThis.fetch;
|
|
37
|
+
if (provided === undefined) {
|
|
38
|
+
throw new Error("No global fetch available; pass `fetch` in the client options (Node < 18).");
|
|
39
|
+
}
|
|
40
|
+
this.fetchImpl = provided;
|
|
41
|
+
this.sleep = options.sleep ?? defaultSleep;
|
|
42
|
+
}
|
|
43
|
+
async post(path, body, headers) {
|
|
44
|
+
const url = `${this.options.baseUrl.replace(/\/+$/, "")}${path}`;
|
|
45
|
+
const payload = JSON.stringify(body);
|
|
46
|
+
let attempt = 0;
|
|
47
|
+
for (;;) {
|
|
48
|
+
let response;
|
|
49
|
+
try {
|
|
50
|
+
response = await this.fetchImpl(url, {
|
|
51
|
+
method: "POST",
|
|
52
|
+
headers: {
|
|
53
|
+
"content-type": "application/json",
|
|
54
|
+
accept: "application/json",
|
|
55
|
+
"user-agent": this.options.userAgent,
|
|
56
|
+
...headers,
|
|
57
|
+
},
|
|
58
|
+
body: payload,
|
|
59
|
+
signal: AbortSignal.timeout(this.options.timeoutMs),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
catch (cause) {
|
|
63
|
+
if (attempt >= this.options.maxRetries) {
|
|
64
|
+
throw new errors_ts_1.SinioConnectionError(`Request to ${url} failed: ${String(cause)}`, cause);
|
|
65
|
+
}
|
|
66
|
+
await this.sleep(this.backoffMs(attempt, null));
|
|
67
|
+
attempt += 1;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (response.ok) {
|
|
71
|
+
return await readJson(response);
|
|
72
|
+
}
|
|
73
|
+
const retryAfter = parseRetryAfter(response.headers.get("retry-after"));
|
|
74
|
+
if (isRetriableStatus(response.status) && attempt < this.options.maxRetries) {
|
|
75
|
+
await this.sleep(this.backoffMs(attempt, retryAfter));
|
|
76
|
+
attempt += 1;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
throw await toApiError(response, retryAfter);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** Exponential backoff with full jitter, unless the server told us how long to wait. */
|
|
83
|
+
backoffMs(attempt, retryAfterSeconds) {
|
|
84
|
+
if (retryAfterSeconds !== null) {
|
|
85
|
+
return retryAfterSeconds * 1000;
|
|
86
|
+
}
|
|
87
|
+
const ceiling = Math.min(this.options.retryBaseDelayMs * 2 ** attempt, 30_000);
|
|
88
|
+
return Math.random() * ceiling;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.Transport = Transport;
|
|
92
|
+
async function readJson(response) {
|
|
93
|
+
const text = await response.text();
|
|
94
|
+
if (text.length === 0) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
return JSON.parse(text);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return text;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async function toApiError(response, retryAfterSeconds) {
|
|
105
|
+
const body = await readJson(response);
|
|
106
|
+
const code = extractCode(body);
|
|
107
|
+
const message = `${response.status} ${response.statusText}: ${extractMessage(body) ?? "no message"}`;
|
|
108
|
+
if (response.status === 401 || response.status === 403) {
|
|
109
|
+
return new errors_ts_1.SinioAuthError(message, response.status, body, code);
|
|
110
|
+
}
|
|
111
|
+
if (response.status === 429) {
|
|
112
|
+
return new errors_ts_1.SinioRateLimitError(message, response.status, body, retryAfterSeconds);
|
|
113
|
+
}
|
|
114
|
+
if (response.status >= 500) {
|
|
115
|
+
return new errors_ts_1.SinioServerError(message, response.status, body, code);
|
|
116
|
+
}
|
|
117
|
+
return new errors_ts_1.SinioRequestError(message, response.status, body, code);
|
|
118
|
+
}
|
|
119
|
+
function extractCode(body) {
|
|
120
|
+
if (typeof body === "object" && body !== null && "code" in body && typeof body.code === "string") {
|
|
121
|
+
return body.code;
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
function extractMessage(body) {
|
|
126
|
+
if (typeof body === "string") {
|
|
127
|
+
return body;
|
|
128
|
+
}
|
|
129
|
+
if (typeof body !== "object" || body === null || !("message" in body)) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
const { message } = body;
|
|
133
|
+
// NestJS's ValidationPipe returns an array of messages, one per failed rule.
|
|
134
|
+
if (Array.isArray(message)) {
|
|
135
|
+
return message.join("; ");
|
|
136
|
+
}
|
|
137
|
+
return typeof message === "string" ? message : null;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/http.ts"],"names":[],"mappings":";;;AAyBA,0CAaC;AAtCD,2CAOqB;AAerB,MAAM,YAAY,GAAG,CAAC,EAAU,EAAiB,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAEtG,qFAAqF;AACrF,SAAgB,eAAe,CAAC,MAAqB,EAAE,MAAc,IAAI,CAAC,GAAG,EAAE;IAC7E,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC/B,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;AAC1C,CAAC;AAED;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,MAAc;IACvC,OAAO,MAAM,KAAK,GAAG,IAAI,MAAM,IAAI,GAAG,CAAC;AACzC,CAAC;AAED,MAAa,SAAS;IACH,OAAO,CAAmB;IAC1B,SAAS,CAAY;IACrB,KAAK,CAAgC;IAEtD,YAAY,OAAyB;QACnC,IAAI,CAAC,OAAO,GAAG,OAAO,C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,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACjG,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,cAAc,CAAC,IAAa;IACnC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,EAAE,CAAC;QACtE,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,EAAE,OAAO,EAAE,GAAG,IAA4B,CAAC;IACjD,6EAA6E;IAC7E,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { SinioClient, SDK_VERSION, type SinioClientOptions } from "./client.ts";
|
|
2
|
+
export { SinioApiError, SinioAuthError, SinioConnectionError, SinioError, SinioRateLimitError, SinioRequestError, SinioServerError, SinioValidationError, } from "./errors.ts";
|
|
3
|
+
export { MAX_EVENT_COUNT, MAX_ITEMS_PER_CALL } from "./serialize.ts";
|
|
4
|
+
export { ASSIGNMENT_RELATIONS, ENTITY_KINDS, EVENT_ROLES, INGESTION_MODES, LOCATION_LEVELS, REJECTION_CODES, isKnownRejectionCode, } from "./vocabularies.ts";
|
|
5
|
+
export type * from "./types.ts";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isKnownRejectionCode = exports.REJECTION_CODES = exports.LOCATION_LEVELS = exports.INGESTION_MODES = exports.EVENT_ROLES = exports.ENTITY_KINDS = exports.ASSIGNMENT_RELATIONS = exports.MAX_ITEMS_PER_CALL = exports.MAX_EVENT_COUNT = exports.SinioValidationError = exports.SinioServerError = exports.SinioRequestError = exports.SinioRateLimitError = exports.SinioError = exports.SinioConnectionError = exports.SinioAuthError = exports.SinioApiError = exports.SDK_VERSION = exports.SinioClient = void 0;
|
|
4
|
+
var client_ts_1 = require("./client.js");
|
|
5
|
+
Object.defineProperty(exports, "SinioClient", { enumerable: true, get: function () { return client_ts_1.SinioClient; } });
|
|
6
|
+
Object.defineProperty(exports, "SDK_VERSION", { enumerable: true, get: function () { return client_ts_1.SDK_VERSION; } });
|
|
7
|
+
var errors_ts_1 = require("./errors.js");
|
|
8
|
+
Object.defineProperty(exports, "SinioApiError", { enumerable: true, get: function () { return errors_ts_1.SinioApiError; } });
|
|
9
|
+
Object.defineProperty(exports, "SinioAuthError", { enumerable: true, get: function () { return errors_ts_1.SinioAuthError; } });
|
|
10
|
+
Object.defineProperty(exports, "SinioConnectionError", { enumerable: true, get: function () { return errors_ts_1.SinioConnectionError; } });
|
|
11
|
+
Object.defineProperty(exports, "SinioError", { enumerable: true, get: function () { return errors_ts_1.SinioError; } });
|
|
12
|
+
Object.defineProperty(exports, "SinioRateLimitError", { enumerable: true, get: function () { return errors_ts_1.SinioRateLimitError; } });
|
|
13
|
+
Object.defineProperty(exports, "SinioRequestError", { enumerable: true, get: function () { return errors_ts_1.SinioRequestError; } });
|
|
14
|
+
Object.defineProperty(exports, "SinioServerError", { enumerable: true, get: function () { return errors_ts_1.SinioServerError; } });
|
|
15
|
+
Object.defineProperty(exports, "SinioValidationError", { enumerable: true, get: function () { return errors_ts_1.SinioValidationError; } });
|
|
16
|
+
var serialize_ts_1 = require("./serialize.js");
|
|
17
|
+
Object.defineProperty(exports, "MAX_EVENT_COUNT", { enumerable: true, get: function () { return serialize_ts_1.MAX_EVENT_COUNT; } });
|
|
18
|
+
Object.defineProperty(exports, "MAX_ITEMS_PER_CALL", { enumerable: true, get: function () { return serialize_ts_1.MAX_ITEMS_PER_CALL; } });
|
|
19
|
+
var vocabularies_ts_1 = require("./vocabularies.js");
|
|
20
|
+
Object.defineProperty(exports, "ASSIGNMENT_RELATIONS", { enumerable: true, get: function () { return vocabularies_ts_1.ASSIGNMENT_RELATIONS; } });
|
|
21
|
+
Object.defineProperty(exports, "ENTITY_KINDS", { enumerable: true, get: function () { return vocabularies_ts_1.ENTITY_KINDS; } });
|
|
22
|
+
Object.defineProperty(exports, "EVENT_ROLES", { enumerable: true, get: function () { return vocabularies_ts_1.EVENT_ROLES; } });
|
|
23
|
+
Object.defineProperty(exports, "INGESTION_MODES", { enumerable: true, get: function () { return vocabularies_ts_1.INGESTION_MODES; } });
|
|
24
|
+
Object.defineProperty(exports, "LOCATION_LEVELS", { enumerable: true, get: function () { return vocabularies_ts_1.LOCATION_LEVELS; } });
|
|
25
|
+
Object.defineProperty(exports, "REJECTION_CODES", { enumerable: true, get: function () { return vocabularies_ts_1.REJECTION_CODES; } });
|
|
26
|
+
Object.defineProperty(exports, "isKnownRejectionCode", { enumerable: true, get: function () { return vocabularies_ts_1.isKnownRejectionCode; } });
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAAgF;AAAvE,wGAAA,WAAW,OAAA;AAAE,wGAAA,WAAW,OAAA;AACjC,yCASqB;AARnB,0GAAA,aAAa,OAAA;AACb,2GAAA,cAAc,OAAA;AACd,iHAAA,oBAAoB,OAAA;AACpB,uGAAA,UAAU,OAAA;AACV,gHAAA,mBAAmB,OAAA;AACnB,8GAAA,iBAAiB,OAAA;AACjB,6GAAA,gBAAgB,OAAA;AAChB,iHAAA,oBAAoB,OAAA;AAEtB,+CAAqE;AAA5D,+GAAA,eAAe,OAAA;AAAE,kHAAA,kBAAkB,OAAA;AAC5C,qDAQ2B;AAPzB,uHAAA,oBAAoB,OAAA;AACpB,+GAAA,YAAY,OAAA;AACZ,8GAAA,WAAW,OAAA;AACX,kHAAA,eAAe,OAAA;AACf,kHAAA,eAAe,OAAA;AACf,kHAAA,eAAe,OAAA;AACf,uHAAA,oBAAoB,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { AssignmentInput, AssignmentRelation, EntityInput, EntityKind, EventRole, IngestionMode, JsonObject, LocationInput, LocationLevel, SinioEvent, Timestamp } from "./types.ts";
|
|
2
|
+
/** The API caps every collection at 500 items per call. */
|
|
3
|
+
export declare const MAX_ITEMS_PER_CALL = 500;
|
|
4
|
+
/** The most units one event may stand for. */
|
|
5
|
+
export declare const MAX_EVENT_COUNT = 1000000;
|
|
6
|
+
export type WireRoles = {
|
|
7
|
+
readonly [role in EventRole]?: string | undefined;
|
|
8
|
+
};
|
|
9
|
+
export interface WireEvent {
|
|
10
|
+
readonly source_event_id: string;
|
|
11
|
+
readonly source_version?: string | undefined;
|
|
12
|
+
readonly project?: string | undefined;
|
|
13
|
+
readonly type: string;
|
|
14
|
+
readonly label?: string | undefined;
|
|
15
|
+
readonly occurred_at: string;
|
|
16
|
+
readonly roles?: WireRoles | undefined;
|
|
17
|
+
readonly payload?: JsonObject | undefined;
|
|
18
|
+
readonly count?: number | undefined;
|
|
19
|
+
}
|
|
20
|
+
export interface WireEntity {
|
|
21
|
+
readonly external_id: string;
|
|
22
|
+
readonly kind: EntityKind;
|
|
23
|
+
readonly subkind?: string | undefined;
|
|
24
|
+
readonly label?: string | undefined;
|
|
25
|
+
readonly location?: string | undefined;
|
|
26
|
+
readonly attributes?: JsonObject | undefined;
|
|
27
|
+
}
|
|
28
|
+
export interface WireLocation {
|
|
29
|
+
readonly external_id: string;
|
|
30
|
+
readonly kind: LocationLevel;
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly parent?: string | undefined;
|
|
33
|
+
}
|
|
34
|
+
export interface WireAssignment {
|
|
35
|
+
readonly credential: string;
|
|
36
|
+
readonly subject: string;
|
|
37
|
+
readonly relation?: AssignmentRelation | undefined;
|
|
38
|
+
readonly valid_from: string;
|
|
39
|
+
readonly valid_to?: string | undefined;
|
|
40
|
+
}
|
|
41
|
+
export declare function toIso(value: Timestamp, field: string): string;
|
|
42
|
+
export declare function chunk<T>(items: readonly T[], size: number): T[][];
|
|
43
|
+
export declare function requireOneOf<const T extends string>(value: unknown, values: readonly T[], field: string): T;
|
|
44
|
+
export declare function requireList(value: unknown, field: string): readonly unknown[];
|
|
45
|
+
export declare function toWireMode(mode: unknown): IngestionMode;
|
|
46
|
+
export declare function toWireEvent(event: SinioEvent, index: number): WireEvent;
|
|
47
|
+
export declare function toWireEntity(entity: EntityInput, index: number): WireEntity;
|
|
48
|
+
export declare function toWireLocation(location: LocationInput, index: number): WireLocation;
|
|
49
|
+
export declare function toWireAssignment(assignment: AssignmentInput, index: number): WireAssignment;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_EVENT_COUNT = exports.MAX_ITEMS_PER_CALL = void 0;
|
|
4
|
+
exports.toIso = toIso;
|
|
5
|
+
exports.chunk = chunk;
|
|
6
|
+
exports.requireOneOf = requireOneOf;
|
|
7
|
+
exports.requireList = requireList;
|
|
8
|
+
exports.toWireMode = toWireMode;
|
|
9
|
+
exports.toWireEvent = toWireEvent;
|
|
10
|
+
exports.toWireEntity = toWireEntity;
|
|
11
|
+
exports.toWireLocation = toWireLocation;
|
|
12
|
+
exports.toWireAssignment = toWireAssignment;
|
|
13
|
+
const errors_ts_1 = require("./errors.js");
|
|
14
|
+
const vocabularies_ts_1 = require("./vocabularies.js");
|
|
15
|
+
/** The API caps every collection at 500 items per call. */
|
|
16
|
+
exports.MAX_ITEMS_PER_CALL = 500;
|
|
17
|
+
/** The most units one event may stand for. */
|
|
18
|
+
exports.MAX_EVENT_COUNT = 1_000_000;
|
|
19
|
+
// The API's own rule: a `T`, seconds, an optional fraction, then `Z` or an offset. It rejects the
|
|
20
|
+
// event otherwise (`invalid_occurred_at`); refused here, it is a fixable local error before any call.
|
|
21
|
+
const ISO_WITH_OFFSET = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:?\d{2})$/;
|
|
22
|
+
function toIso(value, field) {
|
|
23
|
+
if (value instanceof Date) {
|
|
24
|
+
if (Number.isNaN(value.getTime())) {
|
|
25
|
+
throw new errors_ts_1.SinioValidationError(`${field} is an invalid Date`);
|
|
26
|
+
}
|
|
27
|
+
return value.toISOString();
|
|
28
|
+
}
|
|
29
|
+
if (typeof value !== "string" || !ISO_WITH_OFFSET.test(value)) {
|
|
30
|
+
throw new errors_ts_1.SinioValidationError(`${field} must be an ISO 8601 timestamp with an offset (got ${JSON.stringify(value)})`);
|
|
31
|
+
}
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
/** Drops `undefined` keys so they never reach the wire as `null`. */
|
|
35
|
+
function compact(record) {
|
|
36
|
+
return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined));
|
|
37
|
+
}
|
|
38
|
+
function chunk(items, size) {
|
|
39
|
+
const chunks = [];
|
|
40
|
+
for (let index = 0; index < items.length; index += size) {
|
|
41
|
+
chunks.push(items.slice(index, index + size));
|
|
42
|
+
}
|
|
43
|
+
return chunks;
|
|
44
|
+
}
|
|
45
|
+
// Local checks, each the API's own rule: the types already say it to TypeScript callers, these say it
|
|
46
|
+
// at runtime to plain JavaScript and to values typed loosely (`as`, `any`, parsed JSON).
|
|
47
|
+
function isPlainObject(value) {
|
|
48
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
const prototype = Object.getPrototypeOf(value);
|
|
52
|
+
return prototype === Object.prototype || prototype === null;
|
|
53
|
+
}
|
|
54
|
+
function requireItem(value, field) {
|
|
55
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
56
|
+
throw new errors_ts_1.SinioValidationError(`${field} must be an object (got ${describe(value)})`);
|
|
57
|
+
}
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
function requireString(value, field) {
|
|
61
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
62
|
+
throw new errors_ts_1.SinioValidationError(`${field} is required and must be a non-empty string (got ${describe(value)})`);
|
|
63
|
+
}
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
function optionalString(value, field) {
|
|
67
|
+
if (value !== undefined && typeof value !== "string") {
|
|
68
|
+
throw new errors_ts_1.SinioValidationError(`${field} must be a string (got ${describe(value)})`);
|
|
69
|
+
}
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
function optionalNonEmptyString(value, field) {
|
|
73
|
+
return value === undefined ? undefined : requireString(value, field);
|
|
74
|
+
}
|
|
75
|
+
function optionalObject(value, field) {
|
|
76
|
+
if (value !== undefined && !isPlainObject(value)) {
|
|
77
|
+
throw new errors_ts_1.SinioValidationError(`${field} must be a JSON object (got ${describe(value)})`);
|
|
78
|
+
}
|
|
79
|
+
return value;
|
|
80
|
+
}
|
|
81
|
+
function requireOneOf(value, values, field) {
|
|
82
|
+
if (typeof value !== "string" || !values.includes(value)) {
|
|
83
|
+
throw new errors_ts_1.SinioValidationError(`${field} must be one of ${values.join(", ")} (got ${describe(value)})`);
|
|
84
|
+
}
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
87
|
+
function requireList(value, field) {
|
|
88
|
+
if (!Array.isArray(value)) {
|
|
89
|
+
throw new errors_ts_1.SinioValidationError(`${field} must be an array (got ${describe(value)})`);
|
|
90
|
+
}
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
function toWireMode(mode) {
|
|
94
|
+
return requireOneOf(mode, vocabularies_ts_1.INGESTION_MODES, "mode");
|
|
95
|
+
}
|
|
96
|
+
function describe(value) {
|
|
97
|
+
if (value === undefined) {
|
|
98
|
+
return "undefined";
|
|
99
|
+
}
|
|
100
|
+
if (Array.isArray(value)) {
|
|
101
|
+
return "an array";
|
|
102
|
+
}
|
|
103
|
+
if (value instanceof Date) {
|
|
104
|
+
return "a Date";
|
|
105
|
+
}
|
|
106
|
+
return JSON.stringify(value) ?? String(value);
|
|
107
|
+
}
|
|
108
|
+
function toWireRoles(value, field) {
|
|
109
|
+
if (value === undefined) {
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
const roles = requireItem(value, field);
|
|
113
|
+
for (const key of Object.keys(roles)) {
|
|
114
|
+
if (!vocabularies_ts_1.EVENT_ROLES.includes(key)) {
|
|
115
|
+
throw new errors_ts_1.SinioValidationError(`${field}.${key} is not a role: roles are ${vocabularies_ts_1.EVENT_ROLES.join(", ")}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return compact({
|
|
119
|
+
device: optionalNonEmptyString(roles["device"], `${field}.device`),
|
|
120
|
+
subject: optionalNonEmptyString(roles["subject"], `${field}.subject`),
|
|
121
|
+
location: optionalNonEmptyString(roles["location"], `${field}.location`),
|
|
122
|
+
actor: optionalNonEmptyString(roles["actor"], `${field}.actor`),
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function toWireEvent(event, index) {
|
|
126
|
+
const at = `events[${index}]`;
|
|
127
|
+
const item = requireItem(event, at);
|
|
128
|
+
const count = item["count"];
|
|
129
|
+
if (count !== undefined && (!Number.isInteger(count) || count < 1 || count > exports.MAX_EVENT_COUNT)) {
|
|
130
|
+
throw new errors_ts_1.SinioValidationError(`${at}.count must be an integer between 1 and ${exports.MAX_EVENT_COUNT} (got ${describe(count)})`);
|
|
131
|
+
}
|
|
132
|
+
return compact({
|
|
133
|
+
source_event_id: requireString(item["sourceEventId"], `${at}.sourceEventId`),
|
|
134
|
+
source_version: optionalString(item["sourceVersion"], `${at}.sourceVersion`),
|
|
135
|
+
project: optionalString(item["project"], `${at}.project`),
|
|
136
|
+
type: requireString(item["type"], `${at}.type`),
|
|
137
|
+
label: optionalString(item["label"], `${at}.label`),
|
|
138
|
+
occurred_at: toIso(requireTimestamp(item["occurredAt"], `${at}.occurredAt`), `${at}.occurredAt`),
|
|
139
|
+
roles: toWireRoles(item["roles"], `${at}.roles`),
|
|
140
|
+
payload: optionalObject(item["payload"], `${at}.payload`),
|
|
141
|
+
count: count,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function toWireEntity(entity, index) {
|
|
145
|
+
const at = `entities[${index}]`;
|
|
146
|
+
const item = requireItem(entity, at);
|
|
147
|
+
return compact({
|
|
148
|
+
external_id: requireString(item["externalId"], `${at}.externalId`),
|
|
149
|
+
kind: requireOneOf(item["kind"], vocabularies_ts_1.ENTITY_KINDS, `${at}.kind`),
|
|
150
|
+
subkind: optionalNonEmptyString(item["subkind"], `${at}.subkind`),
|
|
151
|
+
label: optionalString(item["label"], `${at}.label`),
|
|
152
|
+
location: optionalString(item["location"], `${at}.location`),
|
|
153
|
+
attributes: optionalObject(item["attributes"], `${at}.attributes`),
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
function toWireLocation(location, index) {
|
|
157
|
+
const at = `locations[${index}]`;
|
|
158
|
+
const item = requireItem(location, at);
|
|
159
|
+
return compact({
|
|
160
|
+
external_id: requireString(item["externalId"], `${at}.externalId`),
|
|
161
|
+
kind: requireOneOf(item["kind"], vocabularies_ts_1.LOCATION_LEVELS, `${at}.kind`),
|
|
162
|
+
name: requireString(item["name"], `${at}.name`),
|
|
163
|
+
parent: optionalString(item["parent"], `${at}.parent`),
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function toWireAssignment(assignment, index) {
|
|
167
|
+
const at = `assignments[${index}]`;
|
|
168
|
+
const item = requireItem(assignment, at);
|
|
169
|
+
const relation = item["relation"];
|
|
170
|
+
const validFrom = toIso(requireTimestamp(item["validFrom"], `${at}.validFrom`), `${at}.validFrom`);
|
|
171
|
+
const rawValidTo = item["validTo"];
|
|
172
|
+
const validTo = rawValidTo === undefined || rawValidTo === null ? undefined : toIso(rawValidTo, `${at}.validTo`);
|
|
173
|
+
// The API's `invalid_validity_period`: an assignment has to end after it starts.
|
|
174
|
+
if (validTo !== undefined && Date.parse(validTo) <= Date.parse(validFrom)) {
|
|
175
|
+
throw new errors_ts_1.SinioValidationError(`${at}.validTo must be after validFrom (got ${validFrom} -> ${validTo})`);
|
|
176
|
+
}
|
|
177
|
+
return compact({
|
|
178
|
+
credential: requireString(item["credential"], `${at}.credential`),
|
|
179
|
+
subject: requireString(item["subject"], `${at}.subject`),
|
|
180
|
+
relation: relation === undefined ? undefined : requireOneOf(relation, vocabularies_ts_1.ASSIGNMENT_RELATIONS, `${at}.relation`),
|
|
181
|
+
valid_from: validFrom,
|
|
182
|
+
valid_to: validTo,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function requireTimestamp(value, field) {
|
|
186
|
+
if (value === undefined || value === null || value === "") {
|
|
187
|
+
throw new errors_ts_1.SinioValidationError(`${field} is required`);
|
|
188
|
+
}
|
|
189
|
+
return value;
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=serialize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize.js","sourceRoot":"","sources":["../../src/serialize.ts"],"names":[],"mappings":";;;AAkEA,sBAaC;AAOD,sBAMC;AA6CD,oCAKC;AAED,kCAKC;AAED,gCAEC;AAiCD,kCAkBC;AAED,oCAWC;AAED,wCASC;AAED,4CAmBC;AAzPD,2CAAmD;AAcnD,uDAAsH;AAEtH,2DAA2D;AAC9C,QAAA,kBAAkB,GAAG,GAAG,CAAC;AAEtC,8CAA8C;AACjC,QAAA,eAAe,GAAG,SAAS,CAAC;AAEzC,kGAAkG;AAClG,sGAAsG;AACtG,MAAM,eAAe,GAAG,mEAAmE,CA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,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QAC1D,MAAM,IAAI,gCAAoB,CAAC,GAAG,KAAK,cAAc,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,KAAkB,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { AssignmentRelation, EntityKind, EventRole, IngestionMode, LocationLevel, RejectionCode } from "./vocabularies.ts";
|
|
2
|
+
export type { AssignmentRelation, EntityKind, EventRole, IngestionMode, LocationLevel, RejectionCode };
|
|
3
|
+
/**
|
|
4
|
+
* A rejection code as read from a response: one of the known `RejectionCode`s (autocompleted), or
|
|
5
|
+
* any other string the API may add later, kept as is.
|
|
6
|
+
*/
|
|
7
|
+
export type RejectionCodeValue = RejectionCode | (string & {});
|
|
8
|
+
/** A JSON object: `payload` and `attributes` are never an array or a scalar. */
|
|
9
|
+
export type JsonObject = Readonly<Record<string, unknown>>;
|
|
10
|
+
/** An ISO 8601 timestamp *with* an offset, or a `Date`. */
|
|
11
|
+
export type Timestamp = string | Date;
|
|
12
|
+
/**
|
|
13
|
+
* The four structural roles the derivation engine resolves, each a raw, non-empty
|
|
14
|
+
* identifier from the source. Anything else (ticket number, firmware, ...)
|
|
15
|
+
* belongs in `payload`. The API refuses any other key.
|
|
16
|
+
*/
|
|
17
|
+
export type EventRoles = {
|
|
18
|
+
readonly [role in EventRole]?: string;
|
|
19
|
+
};
|
|
20
|
+
export interface SinioEvent {
|
|
21
|
+
/** Identity at the source, stable over time. Part of the idempotency key. */
|
|
22
|
+
readonly sourceEventId: string;
|
|
23
|
+
/** Source-side version, kept for tracing: it plays no part in deduplication. */
|
|
24
|
+
readonly sourceVersion?: string;
|
|
25
|
+
/** Project `external_id`. Only for organization-wide keys (issued on request), which cover several projects; a project key already carries its project. */
|
|
26
|
+
readonly project?: string;
|
|
27
|
+
/** `code` of an event type in the catalog. */
|
|
28
|
+
readonly type: string;
|
|
29
|
+
readonly label?: string;
|
|
30
|
+
/** ISO 8601 with offset. Without an offset the API rejects the event. */
|
|
31
|
+
readonly occurredAt: Timestamp;
|
|
32
|
+
readonly roles?: EventRoles;
|
|
33
|
+
/** Free-form, optional (`{}` when omitted); the readings (battery, signal, ...) are read from it as its source declares them. */
|
|
34
|
+
readonly payload?: JsonObject;
|
|
35
|
+
/** How many units this one event stands for (a button pressed ten times). An integer from 1 to 1,000,000; omitted = 1. */
|
|
36
|
+
readonly count?: number;
|
|
37
|
+
}
|
|
38
|
+
export interface EntityInput {
|
|
39
|
+
readonly externalId: string;
|
|
40
|
+
readonly kind: EntityKind;
|
|
41
|
+
/** Code of the entity's subkind; never empty when given. An unknown code is created undeclared. */
|
|
42
|
+
readonly subkind?: string;
|
|
43
|
+
readonly label?: string;
|
|
44
|
+
/** External id of the location the entity sits in. */
|
|
45
|
+
readonly location?: string;
|
|
46
|
+
/** Free-form JSON object. */
|
|
47
|
+
readonly attributes?: JsonObject;
|
|
48
|
+
}
|
|
49
|
+
export interface LocationInput {
|
|
50
|
+
readonly externalId: string;
|
|
51
|
+
readonly kind: LocationLevel;
|
|
52
|
+
readonly name: string;
|
|
53
|
+
/** External id of the parent location, if any. */
|
|
54
|
+
readonly parent?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface AssignmentInput {
|
|
57
|
+
/** External id of the credential (badge, card, ...). */
|
|
58
|
+
readonly credential: string;
|
|
59
|
+
/** External id of the subject the credential is assigned to. */
|
|
60
|
+
readonly subject: string;
|
|
61
|
+
/** Defaults to `assigned_to`, the only relation today. */
|
|
62
|
+
readonly relation?: AssignmentRelation;
|
|
63
|
+
/** ISO 8601 with offset, or a `Date`. */
|
|
64
|
+
readonly validFrom: Timestamp;
|
|
65
|
+
/** Open-ended when omitted or `null`; otherwise strictly after `validFrom`. */
|
|
66
|
+
readonly validTo?: Timestamp | null;
|
|
67
|
+
}
|
|
68
|
+
export interface EventRejection {
|
|
69
|
+
readonly sourceEventId: string;
|
|
70
|
+
readonly code: RejectionCodeValue;
|
|
71
|
+
readonly message: string;
|
|
72
|
+
}
|
|
73
|
+
export interface ReferenceRejection {
|
|
74
|
+
readonly externalId: string;
|
|
75
|
+
readonly code: RejectionCodeValue;
|
|
76
|
+
readonly message: string;
|
|
77
|
+
}
|
|
78
|
+
export interface AssignmentRejection {
|
|
79
|
+
readonly credential: string;
|
|
80
|
+
readonly subject: string;
|
|
81
|
+
readonly code: RejectionCodeValue;
|
|
82
|
+
readonly message: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Outcome of `sendEvents`. `duplicates` and `revisions` are successes, not
|
|
86
|
+
* errors: replaying a batch is expected and never creates anything twice.
|
|
87
|
+
*/
|
|
88
|
+
export interface SendEventsResult {
|
|
89
|
+
/** Server-side batch ids, one per HTTP call the SDK made (batches are chunked at 500). */
|
|
90
|
+
readonly batchIds: readonly string[];
|
|
91
|
+
readonly accepted: number;
|
|
92
|
+
readonly pendingClassification: number;
|
|
93
|
+
readonly duplicates: number;
|
|
94
|
+
readonly revisions: number;
|
|
95
|
+
readonly rejected: number;
|
|
96
|
+
readonly rejections: readonly EventRejection[];
|
|
97
|
+
/** The key is in test mode: its events are checked and kept apart, never used for detection. */
|
|
98
|
+
readonly testMode: boolean;
|
|
99
|
+
}
|
|
100
|
+
export interface UpsertResult {
|
|
101
|
+
readonly accepted: number;
|
|
102
|
+
readonly rejected: number;
|
|
103
|
+
readonly rejections: readonly ReferenceRejection[];
|
|
104
|
+
}
|
|
105
|
+
export interface AssignmentsResult {
|
|
106
|
+
readonly accepted: number;
|
|
107
|
+
readonly rejected: number;
|
|
108
|
+
readonly rejections: readonly AssignmentRejection[];
|
|
109
|
+
}
|
|
110
|
+
export interface SendEventsOptions {
|
|
111
|
+
/** Defaults to `webhook`. */
|
|
112
|
+
readonly mode?: IngestionMode;
|
|
113
|
+
/**
|
|
114
|
+
* Overrides the client-level source code for this call. Only needed for keys not bound to a
|
|
115
|
+
* single source (organization-wide keys, issued on request).
|
|
116
|
+
*/
|
|
117
|
+
readonly sourceCode?: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Project override, only for organization-wide API keys (issued on request) covering several
|
|
121
|
+
* projects. A project key already carries its project.
|
|
122
|
+
*/
|
|
123
|
+
export interface ProjectOptions {
|
|
124
|
+
/** Project `external_id`. */
|
|
125
|
+
readonly project?: string;
|
|
126
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Ingestion modes. `backfill` persists history without triggering alerts. */
|
|
2
|
+
export declare const INGESTION_MODES: readonly ["webhook", "backfill"];
|
|
3
|
+
export type IngestionMode = (typeof INGESTION_MODES)[number];
|
|
4
|
+
/** Kinds accepted by `POST /v1/entities`. */
|
|
5
|
+
export declare const ENTITY_KINDS: readonly ["device", "subject", "asset", "actor", "credential"];
|
|
6
|
+
export type EntityKind = (typeof ENTITY_KINDS)[number];
|
|
7
|
+
/** Levels accepted by `POST /v1/locations`. */
|
|
8
|
+
export declare const LOCATION_LEVELS: readonly ["site", "zone", "point"];
|
|
9
|
+
export type LocationLevel = (typeof LOCATION_LEVELS)[number];
|
|
10
|
+
/** Relations accepted by `POST /v1/assignments`; `assigned_to` when omitted. */
|
|
11
|
+
export declare const ASSIGNMENT_RELATIONS: readonly ["assigned_to"];
|
|
12
|
+
export type AssignmentRelation = (typeof ASSIGNMENT_RELATIONS)[number];
|
|
13
|
+
/** The four structural roles an event may carry in `roles`. */
|
|
14
|
+
export declare const EVENT_ROLES: readonly ["device", "subject", "location", "actor"];
|
|
15
|
+
export type EventRole = (typeof EVENT_ROLES)[number];
|
|
16
|
+
/**
|
|
17
|
+
* Codes the API returns in `rejections[].code` today. The list may grow (additive changes): a
|
|
18
|
+
* response carrying a code missing here is passed through unchanged, never refused.
|
|
19
|
+
*/
|
|
20
|
+
export declare const REJECTION_CODES: readonly ["payload_too_large", "unknown_project", "unknown_source", "archived_source", "source_mismatch", "ambiguous_source", "invalid_occurred_at", "missing_required_field", "unknown_location", "unknown_parent_location", "overlapping_assignment", "invalid_validity_period"];
|
|
21
|
+
export type RejectionCode = (typeof REJECTION_CODES)[number];
|
|
22
|
+
/** Whether a rejection code is one this SDK version knows, narrowing it to `RejectionCode`. */
|
|
23
|
+
export declare function isKnownRejectionCode(code: string): code is RejectionCode;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// The closed vocabularies of the ingestion API, each defined once: the value list (used by the local
|
|
3
|
+
// checks) and the type derived from it. They mirror the API contract exactly.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.REJECTION_CODES = exports.EVENT_ROLES = exports.ASSIGNMENT_RELATIONS = exports.LOCATION_LEVELS = exports.ENTITY_KINDS = exports.INGESTION_MODES = void 0;
|
|
6
|
+
exports.isKnownRejectionCode = isKnownRejectionCode;
|
|
7
|
+
/** Ingestion modes. `backfill` persists history without triggering alerts. */
|
|
8
|
+
exports.INGESTION_MODES = ["webhook", "backfill"];
|
|
9
|
+
/** Kinds accepted by `POST /v1/entities`. */
|
|
10
|
+
exports.ENTITY_KINDS = ["device", "subject", "asset", "actor", "credential"];
|
|
11
|
+
/** Levels accepted by `POST /v1/locations`. */
|
|
12
|
+
exports.LOCATION_LEVELS = ["site", "zone", "point"];
|
|
13
|
+
/** Relations accepted by `POST /v1/assignments`; `assigned_to` when omitted. */
|
|
14
|
+
exports.ASSIGNMENT_RELATIONS = ["assigned_to"];
|
|
15
|
+
/** The four structural roles an event may carry in `roles`. */
|
|
16
|
+
exports.EVENT_ROLES = ["device", "subject", "location", "actor"];
|
|
17
|
+
/**
|
|
18
|
+
* Codes the API returns in `rejections[].code` today. The list may grow (additive changes): a
|
|
19
|
+
* response carrying a code missing here is passed through unchanged, never refused.
|
|
20
|
+
*/
|
|
21
|
+
exports.REJECTION_CODES = [
|
|
22
|
+
"payload_too_large",
|
|
23
|
+
"unknown_project",
|
|
24
|
+
"unknown_source",
|
|
25
|
+
"archived_source",
|
|
26
|
+
"source_mismatch",
|
|
27
|
+
"ambiguous_source",
|
|
28
|
+
"invalid_occurred_at",
|
|
29
|
+
"missing_required_field",
|
|
30
|
+
"unknown_location",
|
|
31
|
+
"unknown_parent_location",
|
|
32
|
+
"overlapping_assignment",
|
|
33
|
+
"invalid_validity_period",
|
|
34
|
+
];
|
|
35
|
+
/** Whether a rejection code is one this SDK version knows, narrowing it to `RejectionCode`. */
|
|
36
|
+
function isKnownRejectionCode(code) {
|
|
37
|
+
return exports.REJECTION_CODES.includes(code);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=vocabularies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vocabularies.js","sourceRoot":"","sources":["../../src/vocabularies.ts"],"names":[],"mappings":";AAAA,qGAAqG;AACrG,8EAA8E;;;AA2C9E,oDAEC;AA3CD,8EAA8E;AACjE,QAAA,eAAe,GAAG,CAAC,SAAS,EAAE,UAAU,CAAU,CAAC;AAGhE,6CAA6C;AAChC,QAAA,YAAY,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAU,CAAC;AAG3F,+CAA+C;AAClC,QAAA,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAU,CAAC;AAGlE,gFAAgF;AACnE,QAAA,oBAAoB,GAAG,CAAC,aAAa,CAAU,CAAC;AAG7D,+DAA+D;AAClD,QAAA,WAAW,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,CAAU,CAAC;AAG/E;;;GAGG;AACU,QAAA,eAAe,GAAG;IAC7B,mBAAmB;IACnB,iBAAiB;IACjB,gBAAgB;IAChB,iBAAiB;IACjB,iBAAiB;IACjB,kBAAkB;IAClB,qBAAqB;IACrB,wBAAwB;IACxB,kBAAkB;IAClB,yBAAyB;IACzB,wBAAwB;IACxB,yBAAyB;CACjB,CAAC;AAGX,+FAA+F;AAC/F,SAAgB,oBAAoB,CAAC,IAAY;IAC/C,OAAQ,uBAAqC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC/D,CAAC"}
|