@netwo/saas-sdk-v1 0.0.0-stage → 1.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/LICENSE +21 -0
- package/README.md +118 -2
- package/fesm2022/netwo-saas-sdk-v1-openapi.zod-C8EyoRPK.mjs +3806 -0
- package/fesm2022/netwo-saas-sdk-v1-openapi.zod-C8EyoRPK.mjs.map +1 -0
- package/fesm2022/netwo-saas-sdk-v1.mjs +43 -0
- package/fesm2022/netwo-saas-sdk-v1.mjs.map +1 -0
- package/package.json +36 -3
- package/types/netwo-saas-sdk-v1.d.ts +15955 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defineInterceptor, apiSchema } from '@netwo/openapi-client';
|
|
2
|
+
import { headers } from '@netwo/openapi-client/interceptors';
|
|
3
|
+
|
|
4
|
+
/** The actor on behalf of whom the request is sent. */
|
|
5
|
+
const ACTOR_SLUG_HEADER = 'X-Actor-Slug';
|
|
6
|
+
/** The API key authenticating the requests. */
|
|
7
|
+
const API_KEY_HEADER = 'X-Api-Key';
|
|
8
|
+
/** The targeted environment. */
|
|
9
|
+
const REALM_HEADER = 'X-Realm';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Sets the authentication headers of the public API v1, when the request does not set them.
|
|
13
|
+
* The handlers run in the environment context (they can use `inject()` in Angular).
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* interceptors: [netwoV1Auth({ apiKey: () => env.NETWO_API_KEY, actorSlug: () => env.NETWO_ACTOR_SLUG })]
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* `client.without(netwoV1Auth)` removes it.
|
|
20
|
+
*/
|
|
21
|
+
const netwoV1Auth = defineInterceptor(({ apiKey, actorSlug, realm }) => headers({
|
|
22
|
+
[API_KEY_HEADER]: apiKey,
|
|
23
|
+
...(actorSlug && { [ACTOR_SLUG_HEADER]: actorSlug }),
|
|
24
|
+
...(realm && { [REALM_HEADER]: realm }),
|
|
25
|
+
}).intercept);
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The public API v1 of Netwo (`https://api.netwo.io/api/v1/...`).
|
|
29
|
+
*
|
|
30
|
+
* The requests are authenticated by an API key. `X-Actor-Slug` and `X-Realm` are set by the client
|
|
31
|
+
* (`netwoV1Auth()` interceptor), so they are optional in the requests.
|
|
32
|
+
*/
|
|
33
|
+
const netwoV1Schema = apiSchema('saas-v1', {
|
|
34
|
+
// The responses are validated, the Zod schemas are loaded on demand (first request).
|
|
35
|
+
validators: () => import('./netwo-saas-sdk-v1-openapi.zod-C8EyoRPK.mjs'),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Generated bundle index. Do not edit.
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
export { ACTOR_SLUG_HEADER, API_KEY_HEADER, REALM_HEADER, netwoV1Auth, netwoV1Schema };
|
|
43
|
+
//# sourceMappingURL=netwo-saas-sdk-v1.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"netwo-saas-sdk-v1.mjs","sources":["../../../../../../libs/saas/sdk/v1/src/lib/headers.ts","../../../../../../libs/saas/sdk/v1/src/lib/auth.ts","../../../../../../libs/saas/sdk/v1/src/lib/schema.ts","../../../../../../libs/saas/sdk/v1/src/netwo-saas-sdk-v1.ts"],"sourcesContent":["/** The actor on behalf of whom the request is sent. */\nexport const ACTOR_SLUG_HEADER = 'X-Actor-Slug';\n\n/** The API key authenticating the requests. */\nexport const API_KEY_HEADER = 'X-Api-Key';\n\n/** The targeted environment. */\nexport const REALM_HEADER = 'X-Realm';\n","import { defineInterceptor } from '@netwo/openapi-client';\nimport { HeaderHandler, headers } from '@netwo/openapi-client/interceptors';\nimport { ACTOR_SLUG_HEADER, API_KEY_HEADER, REALM_HEADER } from './headers';\n\nexport interface NetwoV1AuthOptions {\n /** The API key authenticating the requests. */\n readonly apiKey: HeaderHandler;\n /** The actor on behalf of whom the requests are sent. */\n readonly actorSlug?: HeaderHandler;\n /** The targeted environment. */\n readonly realm?: HeaderHandler;\n}\n\n/**\n * Sets the authentication headers of the public API v1, when the request does not set them.\n * The handlers run in the environment context (they can use `inject()` in Angular).\n *\n * ```ts\n * interceptors: [netwoV1Auth({ apiKey: () => env.NETWO_API_KEY, actorSlug: () => env.NETWO_ACTOR_SLUG })]\n * ```\n *\n * `client.without(netwoV1Auth)` removes it.\n */\nexport const netwoV1Auth = defineInterceptor(\n ({ apiKey, actorSlug, realm }: NetwoV1AuthOptions) =>\n headers({\n [API_KEY_HEADER]: apiKey,\n ...(actorSlug && { [ACTOR_SLUG_HEADER]: actorSlug }),\n ...(realm && { [REALM_HEADER]: realm }),\n }).intercept,\n);\n","import { apiSchema } from '@netwo/openapi-client';\nimport type { ACTOR_SLUG_HEADER, REALM_HEADER } from './headers';\nimport type { OpenApi } from './openapi';\n\n/**\n * The public API v1 of Netwo (`https://api.netwo.io/api/v1/...`).\n *\n * The requests are authenticated by an API key. `X-Actor-Slug` and `X-Realm` are set by the client\n * (`netwoV1Auth()` interceptor), so they are optional in the requests.\n */\nexport const netwoV1Schema = apiSchema<\n OpenApi,\n { providedHeaders: typeof REALM_HEADER | typeof ACTOR_SLUG_HEADER }\n>('saas-v1', {\n // The responses are validated, the Zod schemas are loaded on demand (first request).\n validators: () => import('./openapi.zod'),\n});\n\n/**\n * The type of the schema, to derive the types of the API with the helpers of `@netwo/openapi-client`:\n * `SchemaModels<NetwoV1Schema>['HttpCartDiscount']`, `SchemaResponseBody<NetwoV1Schema, 'get', '/api/v1/cart'>`…\n */\nexport type NetwoV1Schema = typeof netwoV1Schema;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAAA;AACO,MAAM,iBAAiB,GAAG;AAEjC;AACO,MAAM,cAAc,GAAG;AAE9B;AACO,MAAM,YAAY,GAAG;;ACM5B;;;;;;;;;AASG;AACI,MAAM,WAAW,GAAG,iBAAiB,CAC1C,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAsB,KAC/C,OAAO,CAAC;IACN,CAAC,cAAc,GAAG,MAAM;IACxB,IAAI,SAAS,IAAI,EAAE,CAAC,iBAAiB,GAAG,SAAS,EAAE,CAAC;IACpD,IAAI,KAAK,IAAI,EAAE,CAAC,YAAY,GAAG,KAAK,EAAE,CAAC;CACxC,CAAC,CAAC,SAAS;;ACzBhB;;;;;AAKG;AACI,MAAM,aAAa,GAAG,SAAS,CAGpC,SAAS,EAAE;;AAEX,IAAA,UAAU,EAAE,MAAM,OAAO,8CAAe,CAAC;AAC1C,CAAA;;AChBD;;AAEG;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netwo/saas-sdk-v1",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Typed schema and authentication of the Netwo public API v1, for @netwo/openapi-client.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"netwo",
|
|
7
|
+
"sdk",
|
|
8
|
+
"api-client",
|
|
9
|
+
"openapi",
|
|
10
|
+
"typescript",
|
|
11
|
+
"angular",
|
|
12
|
+
"rxjs"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"homepage": "https://www.netwo.io",
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"zod": "^4.0.0",
|
|
22
|
+
"tslib": "^2.3.0"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"@netwo/openapi-client": "^1.0.0"
|
|
26
|
+
},
|
|
27
|
+
"module": "fesm2022/netwo-saas-sdk-v1.mjs",
|
|
28
|
+
"typings": "types/netwo-saas-sdk-v1.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
"./package.json": {
|
|
31
|
+
"default": "./package.json"
|
|
32
|
+
},
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./types/netwo-saas-sdk-v1.d.ts",
|
|
35
|
+
"default": "./fesm2022/netwo-saas-sdk-v1.mjs"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"type": "module"
|
|
6
39
|
}
|