@de./sdk 2.0.0 → 2.1.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/dist/allend/Access.js +2 -0
- package/dist/allend/Access.js.map +1 -1
- package/dist/baseUrl.d.ts +3 -5
- package/dist/baseUrl.js +3 -5
- package/dist/baseUrl.js.map +1 -1
- package/dist/core.d.ts +1 -0
- package/dist/core.js +3 -1
- package/dist/core.js.map +1 -1
- package/dist/response.d.ts +9 -0
- package/dist/response.js +42 -0
- package/dist/response.js.map +1 -0
- package/package.json +2 -2
- package/src/allend/Access.ts +3 -0
- package/src/baseUrl.ts +3 -5
- package/src/core.ts +1 -0
- package/src/response.ts +38 -0
package/dist/allend/Access.js
CHANGED
|
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
const baseUrl_1 = require("../baseUrl");
|
|
40
40
|
const error_1 = __importDefault(require("../error"));
|
|
41
|
+
const response_1 = require("../response");
|
|
41
42
|
const USER_ACCOUNT_SERVICE = 'De.API';
|
|
42
43
|
/**
|
|
43
44
|
* Resolve a fetch implementation for the host runtime.
|
|
@@ -164,6 +165,7 @@ class AccessManager {
|
|
|
164
165
|
* look like a workspace being told no, which is precisely the bug that
|
|
165
166
|
* hid `/LSP/invitation/agent` behind a plausible-looking failure.
|
|
166
167
|
*/
|
|
168
|
+
(0, response_1.rememberStatus)(body, response.status);
|
|
167
169
|
if (typeof (body === null || body === void 0 ? void 0 : body.error) !== 'boolean')
|
|
168
170
|
throw new error_1.default((body === null || body === void 0 ? void 0 : body.message) || `${options.method} ${url} — ${response.status} ${response.statusText || 'not a De. response'}`, response.status, body);
|
|
169
171
|
return body;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Access.js","sourceRoot":"","sources":["../../src/allend/Access.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;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ASEURL: {
|
|
|
38
38
|
* It is not reachable through the API host: de.arch serves no `/workspace`
|
|
39
39
|
* routes, so a client pointed there gets 404 for the whole surface.
|
|
40
40
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* is also what a self-hosted De. needs, and what a dev machine running
|
|
45
|
-
* de.workspace on a port other than 22200 needs.
|
|
41
|
+
* Pass `baseUrl` to address a host that differs — what a self-hosted De.
|
|
42
|
+
* needs, and what a dev machine running de.workspace on a port other than
|
|
43
|
+
* 22200 needs.
|
|
46
44
|
*/
|
|
47
45
|
export declare const WSP_SERVER_BASEURL: {
|
|
48
46
|
dev: string;
|
package/dist/baseUrl.js
CHANGED
|
@@ -43,11 +43,9 @@ exports.API_SERVER_BASEURL = {
|
|
|
43
43
|
* It is not reachable through the API host: de.arch serves no `/workspace`
|
|
44
44
|
* routes, so a client pointed there gets 404 for the whole surface.
|
|
45
45
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* is also what a self-hosted De. needs, and what a dev machine running
|
|
50
|
-
* de.workspace on a port other than 22200 needs.
|
|
46
|
+
* Pass `baseUrl` to address a host that differs — what a self-hosted De.
|
|
47
|
+
* needs, and what a dev machine running de.workspace on a port other than
|
|
48
|
+
* 22200 needs.
|
|
51
49
|
*/
|
|
52
50
|
exports.WSP_SERVER_BASEURL = {
|
|
53
51
|
dev: `http://localhost:${DEV_PORTS.WSP}`,
|
package/dist/baseUrl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseUrl.js","sourceRoot":"","sources":["../src/baseUrl.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;
|
|
1
|
+
{"version":3,"file":"baseUrl.js","sourceRoot":"","sources":["../src/baseUrl.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAkEH,0BAOC;AAvED,MAAM,SAAS,GAAG;IACjB,GAAG,EAAE,KAAK;IACV,GA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,CAAC,CAAC,UAAU,WAAW,IAAI,SAAS,CAAE,MAAM,CAAE,EAAE;QAChD,CAAC,CAAC,GAAG,CAAA;AACV,CAAC"}
|
package/dist/core.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export { default as Workflows } from './allend/Workflows';
|
|
|
20
20
|
export type { WorkflowsConfig } from './allend/Workflows';
|
|
21
21
|
export { default as Utils } from './utils';
|
|
22
22
|
export { default as APIError } from './error';
|
|
23
|
+
export { statusOf } from './response';
|
|
23
24
|
export { default as IoTClient } from './allend/IoTClient';
|
|
24
25
|
export type { IoTClientOptions } from './allend/IoTClient';
|
|
25
26
|
export { default as Customer } from './allend/Customer';
|
package/dist/core.js
CHANGED
|
@@ -20,7 +20,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
20
20
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.core = exports.DClient = exports.Utilities = exports.Queries = exports.Agent = exports.Customer = exports.IoTClient = exports.APIError = exports.Utils = exports.Workflows = exports.Realtime = exports.Workspace = exports.IoTBackendRecords = exports.IoTSP = exports.DEV = exports.CSP = exports.LSP = exports.Pipelines = exports.Tracking = exports.OTPAuth = exports.Auth = void 0;
|
|
23
|
+
exports.core = exports.DClient = exports.Utilities = exports.Queries = exports.Agent = exports.Customer = exports.IoTClient = exports.statusOf = exports.APIError = exports.Utils = exports.Workflows = exports.Realtime = exports.Workspace = exports.IoTBackendRecords = exports.IoTSP = exports.DEV = exports.CSP = exports.LSP = exports.Pipelines = exports.Tracking = exports.OTPAuth = exports.Auth = void 0;
|
|
24
24
|
// ── Named exports (preferred — tree-shakeable) ────────────────────────────────
|
|
25
25
|
// Server-side auth: connector credentials → access token
|
|
26
26
|
var Auth_1 = require("./backend/Auth");
|
|
@@ -56,6 +56,8 @@ var utils_1 = require("./utils");
|
|
|
56
56
|
Object.defineProperty(exports, "Utils", { enumerable: true, get: function () { return __importDefault(utils_1).default; } });
|
|
57
57
|
var error_1 = require("./error");
|
|
58
58
|
Object.defineProperty(exports, "APIError", { enumerable: true, get: function () { return __importDefault(error_1).default; } });
|
|
59
|
+
var response_1 = require("./response");
|
|
60
|
+
Object.defineProperty(exports, "statusOf", { enumerable: true, get: function () { return response_1.statusOf; } });
|
|
59
61
|
// ── Client layer (allend) ─────────────────────────────────────────────────────
|
|
60
62
|
// DClient ({ Client, Event }), the IoT socket client, and the customer/agent/
|
|
61
63
|
// query surfaces.
|
package/dist/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";AAAA,iFAAiF;AACjF,EAAE;AACF,4EAA4E;AAC5E,EAAE;AACF,6EAA6E;AAC7E,4EAA4E;AAC5E,8EAA8E;AAC9E,0EAA0E;AAC1E,0EAA0E;AAC1E,WAAW;AACX,EAAE;AACF,0BAA0B;AAC1B,EAAE;AACF,mEAAmE;AACnE,sEAAsE;AACtE,EAAE;AACF,gFAAgF;;;;;;AAEhF,iFAAiF;AAEjF,yDAAyD;AACzD,uCAAgD;AAAvC,6GAAA,OAAO,OAAQ;AAGxB,yCAAyC;AACzC,4CAAqD;AAA5C,mHAAA,OAAO,OAAW;AAE3B,0CAA0C;AAC1C,8CAAuD;AAA9C,qHAAA,OAAO,OAAY;AAG5B,gDAAyD;AAAhD,uHAAA,OAAO,OAAa;AAG7B,oCAA6C;AAApC,2GAAA,OAAO,OAAO;AAGvB,oCAA6C;AAApC,2GAAA,OAAO,OAAO;AAGvB,oCAA6C;AAApC,2GAAA,OAAO,OAAO;AAGvB,qEAAqE;AACrE,wCAA+E;AAAtE,+GAAA,OAAO,OAAS;AAAE,0GAAA,OAAO,OAAqB;AAGvD,gDAAyD;AAAhD,uHAAA,OAAO,OAAa;AAG7B,4CAA4C;AAC5C,8CAAuD;AAA9C,qHAAA,OAAO,OAAY;AAE5B,sBAAsB;AACtB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
2
|
+
export declare const rememberStatus: (body: unknown, status: number) => void;
|
|
3
|
+
/**
|
|
4
|
+
* The HTTP status the given envelope arrived with.
|
|
5
|
+
*
|
|
6
|
+
* `undefined` when the object did not come from this SDK's transport, or when
|
|
7
|
+
* the call threw instead of returning — `APIError` carries its own `status`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const statusOf: (envelope: unknown) => number | undefined;
|
package/dist/response.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.statusOf = exports.rememberStatus = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The HTTP status a returned envelope arrived with.
|
|
6
|
+
*
|
|
7
|
+
* Clients return De.'s `{ error, status, message, data }` envelope, which is
|
|
8
|
+
* what makes `status` — the precise refusal code — reachable. It carries no
|
|
9
|
+
* HTTP status, and for most callers that is right: the envelope says more than
|
|
10
|
+
* a number can.
|
|
11
|
+
*
|
|
12
|
+
* A proxy is the exception. It answers its own client with an HTTP status, and
|
|
13
|
+
* mapping every De. refusal onto a generic 400 loses the distinction between
|
|
14
|
+
* "no such order" and "you may not do that" for whoever is downstream.
|
|
15
|
+
*
|
|
16
|
+
* So the status is kept beside the response rather than inside it: the type
|
|
17
|
+
* stays exactly the envelope, and a caller that needs the number asks for it,
|
|
18
|
+
* keyed on the object it was given. Keying on identity rather than on a
|
|
19
|
+
* mutable field is what makes it safe under concurrency — two calls in flight
|
|
20
|
+
* cannot read each other's status.
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* const answer = await lsp.orders.get( reference )
|
|
24
|
+
* if( answer.error ) throw new HTTPException( statusOf( answer ) ?? 400, ... )
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
const statuses = new WeakMap();
|
|
28
|
+
/** Record the status for a parsed response body. Called by the transport. */
|
|
29
|
+
const rememberStatus = (body, status) => {
|
|
30
|
+
if (body && typeof body === 'object')
|
|
31
|
+
statuses.set(body, status);
|
|
32
|
+
};
|
|
33
|
+
exports.rememberStatus = rememberStatus;
|
|
34
|
+
/**
|
|
35
|
+
* The HTTP status the given envelope arrived with.
|
|
36
|
+
*
|
|
37
|
+
* `undefined` when the object did not come from this SDK's transport, or when
|
|
38
|
+
* the call threw instead of returning — `APIError` carries its own `status`.
|
|
39
|
+
*/
|
|
40
|
+
const statusOf = (envelope) => envelope && typeof envelope === 'object' ? statuses.get(envelope) : undefined;
|
|
41
|
+
exports.statusOf = statusOf;
|
|
42
|
+
//# sourceMappingURL=response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../src/response.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAkB,CAAA;AAE9C,6EAA6E;AACtE,MAAM,cAAc,GAAG,CAAE,IAAa,EAAE,MAAc,EAAS,EAAE;IACvE,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAG,QAAQ,CAAC,GAAG,CAAE,IAAc,EAAE,MAAM,CAAE,CAAA;AAC9E,CAAC,CAAA;AAFY,QAAA,cAAc,kBAE1B;AAED;;;;;GAKG;AACI,MAAM,QAAQ,GAAG,CAAE,QAAiB,EAAuB,EAAE,CACnE,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAE,QAAkB,CAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AAD7E,QAAA,QAAQ,YACqE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@de./sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Complete SDK pack for MSI (Map Service Interface), IoTClient and DClient services — web, server and React Native",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"test:event": "npm run build:tsc && jest test/event.test.js"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@de./types": "^2.
|
|
44
|
+
"@de./types": "^2.1.0",
|
|
45
45
|
"events": "^3.3.0",
|
|
46
46
|
"iframe.io": "^1.1.0",
|
|
47
47
|
"node-fetch": "2.6.1",
|
package/src/allend/Access.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { AccessOptions, UserSession } from '../types/access'
|
|
|
2
2
|
import type { HTTPRequestOptions } from '../types'
|
|
3
3
|
import { baseURL } from '../baseUrl'
|
|
4
4
|
import APIError from '../error'
|
|
5
|
+
import { rememberStatus } from '../response'
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Which service the client addresses.
|
|
@@ -168,6 +169,8 @@ export default class AccessManager {
|
|
|
168
169
|
* look like a workspace being told no, which is precisely the bug that
|
|
169
170
|
* hid `/LSP/invitation/agent` behind a plausible-looking failure.
|
|
170
171
|
*/
|
|
172
|
+
rememberStatus( body, response.status )
|
|
173
|
+
|
|
171
174
|
if( typeof body?.error !== 'boolean' )
|
|
172
175
|
throw new APIError(
|
|
173
176
|
body?.message || `${options.method} ${url} — ${response.status} ${response.statusText || 'not a De. response'}`,
|
package/src/baseUrl.ts
CHANGED
|
@@ -41,11 +41,9 @@ export const API_SERVER_BASEURL = {
|
|
|
41
41
|
* It is not reachable through the API host: de.arch serves no `/workspace`
|
|
42
42
|
* routes, so a client pointed there gets 404 for the whole surface.
|
|
43
43
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* is also what a self-hosted De. needs, and what a dev machine running
|
|
48
|
-
* de.workspace on a port other than 22200 needs.
|
|
44
|
+
* Pass `baseUrl` to address a host that differs — what a self-hosted De.
|
|
45
|
+
* needs, and what a dev machine running de.workspace on a port other than
|
|
46
|
+
* 22200 needs.
|
|
49
47
|
*/
|
|
50
48
|
export const WSP_SERVER_BASEURL = {
|
|
51
49
|
dev: `http://localhost:${DEV_PORTS.WSP}`,
|
package/src/core.ts
CHANGED
|
@@ -59,6 +59,7 @@ export type { WorkflowsConfig } from './allend/Workflows'
|
|
|
59
59
|
export { default as Utils } from './utils'
|
|
60
60
|
|
|
61
61
|
export { default as APIError } from './error'
|
|
62
|
+
export { statusOf } from './response'
|
|
62
63
|
|
|
63
64
|
// ── Client layer (allend) ─────────────────────────────────────────────────────
|
|
64
65
|
// DClient ({ Client, Event }), the IoT socket client, and the customer/agent/
|
package/src/response.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The HTTP status a returned envelope arrived with.
|
|
3
|
+
*
|
|
4
|
+
* Clients return De.'s `{ error, status, message, data }` envelope, which is
|
|
5
|
+
* what makes `status` — the precise refusal code — reachable. It carries no
|
|
6
|
+
* HTTP status, and for most callers that is right: the envelope says more than
|
|
7
|
+
* a number can.
|
|
8
|
+
*
|
|
9
|
+
* A proxy is the exception. It answers its own client with an HTTP status, and
|
|
10
|
+
* mapping every De. refusal onto a generic 400 loses the distinction between
|
|
11
|
+
* "no such order" and "you may not do that" for whoever is downstream.
|
|
12
|
+
*
|
|
13
|
+
* So the status is kept beside the response rather than inside it: the type
|
|
14
|
+
* stays exactly the envelope, and a caller that needs the number asks for it,
|
|
15
|
+
* keyed on the object it was given. Keying on identity rather than on a
|
|
16
|
+
* mutable field is what makes it safe under concurrency — two calls in flight
|
|
17
|
+
* cannot read each other's status.
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* const answer = await lsp.orders.get( reference )
|
|
21
|
+
* if( answer.error ) throw new HTTPException( statusOf( answer ) ?? 400, ... )
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
const statuses = new WeakMap<object, number>()
|
|
25
|
+
|
|
26
|
+
/** Record the status for a parsed response body. Called by the transport. */
|
|
27
|
+
export const rememberStatus = ( body: unknown, status: number ): void => {
|
|
28
|
+
if( body && typeof body === 'object' ) statuses.set( body as object, status )
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The HTTP status the given envelope arrived with.
|
|
33
|
+
*
|
|
34
|
+
* `undefined` when the object did not come from this SDK's transport, or when
|
|
35
|
+
* the call threw instead of returning — `APIError` carries its own `status`.
|
|
36
|
+
*/
|
|
37
|
+
export const statusOf = ( envelope: unknown ): number | undefined =>
|
|
38
|
+
envelope && typeof envelope === 'object' ? statuses.get( envelope as object ) : undefined
|