@synapseone/sdk 0.0.0-stage → 0.7.0-dev.41

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/dist/lds.d.ts ADDED
@@ -0,0 +1,82 @@
1
+ import { HttpClient } from './_http';
2
+ /** LDS attribute/datasource visibility (`internal` is settable but not listable via `?visibility`). */
3
+ export type LdsVisibility = 'public' | 'restricted' | 'internal';
4
+ /** NGSI-LD attribute types accepted by PUT /v1/lds/datasources/:id/attributes. */
5
+ export type LdsAttributeType = 'Property' | 'Relationship' | 'GeoProperty';
6
+ /** Body of POST /v1/lds/datasources; PATCH accepts a partial of this. */
7
+ export interface LdsDatasourceInput {
8
+ name: string;
9
+ slug?: string;
10
+ entityType: string;
11
+ license: string;
12
+ licenseUrl?: string;
13
+ contexts?: string[];
14
+ defaultVisibility?: LdsVisibility;
15
+ description?: string;
16
+ orgId?: string;
17
+ accountId?: string;
18
+ }
19
+ /** One attribute row for PUT /v1/lds/datasources/:id/attributes. */
20
+ export interface LdsAttributeInput {
21
+ name: string;
22
+ ngsiLdType?: LdsAttributeType;
23
+ visibility?: LdsVisibility;
24
+ description?: string;
25
+ sourceField?: string;
26
+ }
27
+ /** Query for GET /v1/lds/datasources/:id/entities (limit 1..500, default 100). */
28
+ export interface LdsEntitiesQuery {
29
+ limit?: number;
30
+ offset?: number;
31
+ visibility?: 'public' | 'restricted';
32
+ }
33
+ /** Result of POST /v1/lds/datasources/:id/records (quarantine reasons are per field). */
34
+ export interface LdsIngestResult {
35
+ ingested: number;
36
+ created: number;
37
+ updated: number;
38
+ quarantined: {
39
+ field: string;
40
+ reason: string;
41
+ }[];
42
+ entities: {
43
+ id: string;
44
+ entityId: string;
45
+ sourceRecordId?: string;
46
+ }[];
47
+ }
48
+ export declare class LdsService {
49
+ private readonly http;
50
+ constructor(http: HttpClient);
51
+ licenses(): Promise<any[]>;
52
+ datasources(query?: {
53
+ orgId?: string;
54
+ accountId?: string;
55
+ }): Promise<any[]>;
56
+ createDatasource(input: LdsDatasourceInput): Promise<unknown>;
57
+ datasource(id: string): Promise<unknown>;
58
+ updateDatasource(id: string, patch: Partial<LdsDatasourceInput>): Promise<unknown>;
59
+ deleteDatasource(id: string): Promise<{
60
+ ok: boolean;
61
+ }>;
62
+ attributes(id: string): Promise<any[]>;
63
+ setAttributes(id: string, attributes: LdsAttributeInput[]): Promise<any[]>;
64
+ /**
65
+ * Ingest into a datasource. `records` accepts a single record object, an
66
+ * array (wrapped as `{records}`), or a pre-wrapped `{records}`/`{record}`
67
+ * body — all three shapes the endpoint accepts.
68
+ */
69
+ ingest(id: string, records: Record<string, unknown> | Record<string, unknown>[]): Promise<LdsIngestResult>;
70
+ /** List NGSI-LD entities; limit 1..500 (default 100), visibility public|restricted only. */
71
+ entities(id: string, query?: LdsEntitiesQuery): Promise<any[]>;
72
+ entity(id: string, entityId: string): Promise<unknown>;
73
+ stats(id: string): Promise<{
74
+ records: number;
75
+ attributes: {
76
+ public: number;
77
+ restricted: number;
78
+ internal: number;
79
+ };
80
+ lastIngestAt: string | null;
81
+ }>;
82
+ }
package/dist/lds.js ADDED
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2026 SynapseOne Contributors
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * LDS (linked-data service) client: datasources, attributes, records,
6
+ * NGSI-LD entities, stats and licenses.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.LdsService = void 0;
10
+ class LdsService {
11
+ http;
12
+ constructor(http) {
13
+ this.http = http;
14
+ }
15
+ licenses() { return this.http.req('/v1/lds/licenses'); }
16
+ datasources(query = {}) {
17
+ const params = new URLSearchParams();
18
+ if (query.orgId)
19
+ params.set('orgId', query.orgId);
20
+ if (query.accountId)
21
+ params.set('accountId', query.accountId);
22
+ const s = params.toString();
23
+ return this.http.req(`/v1/lds/datasources${s ? `?${s}` : ''}`);
24
+ }
25
+ createDatasource(input) {
26
+ return this.http.req('/v1/lds/datasources', { method: 'POST', body: JSON.stringify(input) });
27
+ }
28
+ datasource(id) { return this.http.req(`/v1/lds/datasources/${encodeURIComponent(id)}`); }
29
+ updateDatasource(id, patch) {
30
+ return this.http.req(`/v1/lds/datasources/${encodeURIComponent(id)}`, { method: 'PATCH', body: JSON.stringify(patch) });
31
+ }
32
+ deleteDatasource(id) {
33
+ return this.http.req(`/v1/lds/datasources/${encodeURIComponent(id)}`, { method: 'DELETE' });
34
+ }
35
+ attributes(id) {
36
+ return this.http.req(`/v1/lds/datasources/${encodeURIComponent(id)}/attributes`);
37
+ }
38
+ setAttributes(id, attributes) {
39
+ return this.http.req(`/v1/lds/datasources/${encodeURIComponent(id)}/attributes`, {
40
+ method: 'PUT', body: JSON.stringify({ attributes }),
41
+ });
42
+ }
43
+ /**
44
+ * Ingest into a datasource. `records` accepts a single record object, an
45
+ * array (wrapped as `{records}`), or a pre-wrapped `{records}`/`{record}`
46
+ * body — all three shapes the endpoint accepts.
47
+ */
48
+ ingest(id, records) {
49
+ const body = Array.isArray(records)
50
+ ? { records }
51
+ : records && typeof records === 'object' && ('records' in records || 'record' in records)
52
+ ? records
53
+ : { record: records };
54
+ return this.http.req(`/v1/lds/datasources/${encodeURIComponent(id)}/records`, {
55
+ method: 'POST', body: JSON.stringify(body),
56
+ });
57
+ }
58
+ /** List NGSI-LD entities; limit 1..500 (default 100), visibility public|restricted only. */
59
+ entities(id, query = {}) {
60
+ const allowed = ['limit', 'offset', 'visibility'];
61
+ const params = new URLSearchParams();
62
+ for (const k of allowed) {
63
+ const v = query[k];
64
+ if (v !== undefined && v !== null && String(v) !== '')
65
+ params.set(k, String(v));
66
+ }
67
+ const s = params.toString();
68
+ return this.http.req(`/v1/lds/datasources/${encodeURIComponent(id)}/entities${s ? `?${s}` : ''}`);
69
+ }
70
+ entity(id, entityId) {
71
+ return this.http.req(`/v1/lds/datasources/${encodeURIComponent(id)}/entities/${encodeURIComponent(entityId)}`);
72
+ }
73
+ stats(id) {
74
+ return this.http.req(`/v1/lds/datasources/${encodeURIComponent(id)}/stats`);
75
+ }
76
+ }
77
+ exports.LdsService = LdsService;
@@ -0,0 +1,72 @@
1
+ import { HttpClient } from './_http';
2
+ export declare class QueueService {
3
+ private readonly http;
4
+ constructor(http: HttpClient);
5
+ private q;
6
+ listQueues(): Promise<any[]>;
7
+ createQueue(queue: string, opts?: {
8
+ maxAttempts?: number;
9
+ visibilityTimeoutSeconds?: number;
10
+ }): Promise<unknown>;
11
+ getQueue(queue: string): Promise<unknown>;
12
+ deleteQueue(queue: string): Promise<unknown>;
13
+ purgeQueue(queue: string): Promise<unknown>;
14
+ queueStats(queue: string): Promise<unknown>;
15
+ publish(queue: string, payload: unknown, opts?: {
16
+ delaySeconds?: number;
17
+ maxAttempts?: number;
18
+ headers?: Record<string, unknown>;
19
+ id?: string;
20
+ dedupeKey?: string;
21
+ }): Promise<unknown>;
22
+ /** Publish 1..100 messages; each entry takes the same fields as `publish`. */
23
+ publishBatch(queue: string, messages: Array<Record<string, unknown>>): Promise<{
24
+ queue: string;
25
+ results: any[];
26
+ ok: boolean;
27
+ }>;
28
+ consume(queue: string, opts?: {
29
+ maxMessages?: number;
30
+ visibilityTimeoutSeconds?: number;
31
+ consumer?: string;
32
+ }): Promise<{
33
+ queue: string;
34
+ count: number;
35
+ visibilityTimeoutSeconds: number;
36
+ messages: any[];
37
+ }>;
38
+ ack(queue: string, receipt: string): Promise<unknown>;
39
+ ackMany(queue: string, receipts: string[]): Promise<{
40
+ queue: string;
41
+ results: any[];
42
+ ok: boolean;
43
+ }>;
44
+ nack(queue: string, receipt: string, opts?: {
45
+ requeue?: boolean;
46
+ delaySeconds?: number;
47
+ error?: string;
48
+ }): Promise<unknown>;
49
+ heartbeat(queue: string, receipt: string, opts?: {
50
+ visibilityTimeoutSeconds?: number;
51
+ }): Promise<unknown>;
52
+ peek(queue: string, opts?: {
53
+ limit?: number;
54
+ ready?: boolean;
55
+ }): Promise<{
56
+ queue: string;
57
+ count: number;
58
+ messages: any[];
59
+ }>;
60
+ deadLetters(queue: string, opts?: {
61
+ limit?: number;
62
+ }): Promise<{
63
+ queue: string;
64
+ count: number;
65
+ messages: any[];
66
+ }>;
67
+ replayDead(queue: string, messageId: string, opts?: {
68
+ delaySeconds?: number;
69
+ resetAttempts?: boolean;
70
+ }): Promise<unknown>;
71
+ deleteDead(queue: string, messageId: string): Promise<unknown>;
72
+ }
package/dist/queue.js ADDED
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2026 SynapseOne Contributors
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * SynapseQueue client: queues, publish (delay + dedupe), at-least-once
6
+ * consumption with visibility-timeout leases, ack/nack/heartbeat, retry,
7
+ * dead letters and replay.
8
+ *
9
+ * Delivery model: `consume()` leases messages and returns a `receipt` per
10
+ * message. `ack` when processing succeeds, `nack` to requeue/dead-letter and
11
+ * `heartbeat` to extend long-running leases. Expired leases are redelivered,
12
+ * so consumers must be idempotent.
13
+ *
14
+ * Every operation is scoped to the caller's tenant (org / account / user).
15
+ * Platform callers set `tenant` on the client (x-synapseone-tenant).
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.QueueService = void 0;
19
+ const P = '/v1/queue/queues';
20
+ class QueueService {
21
+ http;
22
+ constructor(http) {
23
+ this.http = http;
24
+ }
25
+ q(queue) {
26
+ return encodeURIComponent(queue);
27
+ }
28
+ // ---- queues ----
29
+ listQueues() { return this.http.req(P); }
30
+ createQueue(queue, opts = {}) {
31
+ return this.http.req(`${P}/${this.q(queue)}`, {
32
+ method: 'PUT',
33
+ body: JSON.stringify({
34
+ ...(opts.maxAttempts !== undefined ? { maxAttempts: opts.maxAttempts } : {}),
35
+ ...(opts.visibilityTimeoutSeconds !== undefined ? { visibilityTimeoutSeconds: opts.visibilityTimeoutSeconds } : {}),
36
+ }),
37
+ });
38
+ }
39
+ getQueue(queue) { return this.http.req(`${P}/${this.q(queue)}`); }
40
+ deleteQueue(queue) { return this.http.req(`${P}/${this.q(queue)}`, { method: 'DELETE' }); }
41
+ purgeQueue(queue) { return this.http.req(`${P}/${this.q(queue)}/purge`, { method: 'POST' }); }
42
+ queueStats(queue) { return this.http.req(`${P}/${this.q(queue)}/stats`); }
43
+ // ---- publish ----
44
+ publish(queue, payload, opts = {}) {
45
+ return this.http.req(`${P}/${this.q(queue)}/messages`, {
46
+ method: 'POST',
47
+ body: JSON.stringify({
48
+ payload,
49
+ ...(opts.delaySeconds !== undefined ? { delaySeconds: opts.delaySeconds } : {}),
50
+ ...(opts.maxAttempts !== undefined ? { maxAttempts: opts.maxAttempts } : {}),
51
+ ...(opts.headers !== undefined ? { headers: opts.headers } : {}),
52
+ ...(opts.id !== undefined ? { id: opts.id } : {}),
53
+ ...(opts.dedupeKey !== undefined ? { dedupeKey: opts.dedupeKey } : {}),
54
+ }),
55
+ });
56
+ }
57
+ /** Publish 1..100 messages; each entry takes the same fields as `publish`. */
58
+ publishBatch(queue, messages) {
59
+ return this.http.req(`${P}/${this.q(queue)}/messages:batch`, {
60
+ method: 'POST', body: JSON.stringify({ messages }),
61
+ });
62
+ }
63
+ // ---- consume / ack / nack / heartbeat ----
64
+ consume(queue, opts = {}) {
65
+ return this.http.req(`${P}/${this.q(queue)}/consume`, {
66
+ method: 'POST',
67
+ body: JSON.stringify({
68
+ ...(opts.maxMessages !== undefined ? { maxMessages: opts.maxMessages } : {}),
69
+ ...(opts.visibilityTimeoutSeconds !== undefined ? { visibilityTimeoutSeconds: opts.visibilityTimeoutSeconds } : {}),
70
+ ...(opts.consumer !== undefined ? { consumer: opts.consumer } : {}),
71
+ }),
72
+ });
73
+ }
74
+ ack(queue, receipt) {
75
+ return this.http.req(`${P}/${this.q(queue)}/ack`, { method: 'POST', body: JSON.stringify({ receipt }) });
76
+ }
77
+ ackMany(queue, receipts) {
78
+ return this.http.req(`${P}/${this.q(queue)}/ack`, {
79
+ method: 'POST', body: JSON.stringify({ receipts }),
80
+ });
81
+ }
82
+ nack(queue, receipt, opts = {}) {
83
+ return this.http.req(`${P}/${this.q(queue)}/nack`, {
84
+ method: 'POST',
85
+ body: JSON.stringify({
86
+ receipt,
87
+ requeue: opts.requeue ?? true,
88
+ ...(opts.delaySeconds !== undefined ? { delaySeconds: opts.delaySeconds } : {}),
89
+ ...(opts.error !== undefined ? { error: opts.error } : {}),
90
+ }),
91
+ });
92
+ }
93
+ heartbeat(queue, receipt, opts = {}) {
94
+ return this.http.req(`${P}/${this.q(queue)}/heartbeat`, {
95
+ method: 'POST',
96
+ body: JSON.stringify({
97
+ receipt,
98
+ ...(opts.visibilityTimeoutSeconds !== undefined ? { visibilityTimeoutSeconds: opts.visibilityTimeoutSeconds } : {}),
99
+ }),
100
+ });
101
+ }
102
+ // ---- inspection / dead letters ----
103
+ peek(queue, opts = {}) {
104
+ const p = new URLSearchParams();
105
+ if (opts.limit !== undefined)
106
+ p.set('limit', String(opts.limit));
107
+ if (opts.ready)
108
+ p.set('ready', 'true');
109
+ const s = p.toString();
110
+ return this.http.req(`${P}/${this.q(queue)}/messages${s ? `?${s}` : ''}`);
111
+ }
112
+ deadLetters(queue, opts = {}) {
113
+ const s = opts.limit !== undefined ? `?limit=${opts.limit}` : '';
114
+ return this.http.req(`${P}/${this.q(queue)}/dead${s}`);
115
+ }
116
+ replayDead(queue, messageId, opts = {}) {
117
+ return this.http.req(`${P}/${this.q(queue)}/dead/${encodeURIComponent(messageId)}/replay`, {
118
+ method: 'POST',
119
+ body: JSON.stringify({
120
+ ...(opts.delaySeconds !== undefined ? { delaySeconds: opts.delaySeconds } : {}),
121
+ ...(opts.resetAttempts ? { resetAttempts: true } : {}),
122
+ }),
123
+ });
124
+ }
125
+ deleteDead(queue, messageId) {
126
+ return this.http.req(`${P}/${this.q(queue)}/dead/${encodeURIComponent(messageId)}`, { method: 'DELETE' });
127
+ }
128
+ }
129
+ exports.QueueService = QueueService;
@@ -0,0 +1 @@
1
+ export {};