@primitivedotdev/sdk 0.26.0 → 0.27.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.
Files changed (47) hide show
  1. package/README.md +2 -2
  2. package/dist/api/index.js +3 -406
  3. package/dist/openapi/index.js +7631 -7
  4. package/package.json +6 -63
  5. package/bin/run.js +0 -20
  6. package/dist/api/generated/client/client.gen.js +0 -235
  7. package/dist/api/generated/client/index.js +0 -6
  8. package/dist/api/generated/client/types.gen.js +0 -2
  9. package/dist/api/generated/client/utils.gen.js +0 -228
  10. package/dist/api/generated/client.gen.js +0 -3
  11. package/dist/api/generated/core/auth.gen.js +0 -14
  12. package/dist/api/generated/core/bodySerializer.gen.js +0 -57
  13. package/dist/api/generated/core/params.gen.js +0 -100
  14. package/dist/api/generated/core/pathSerializer.gen.js +0 -106
  15. package/dist/api/generated/core/queryKeySerializer.gen.js +0 -92
  16. package/dist/api/generated/core/serverSentEvents.gen.js +0 -132
  17. package/dist/api/generated/core/types.gen.js +0 -2
  18. package/dist/api/generated/core/utils.gen.js +0 -87
  19. package/dist/api/generated/index.js +0 -2
  20. package/dist/api/generated/sdk.gen.js +0 -878
  21. package/dist/api/generated/types.gen.js +0 -2
  22. package/dist/api/verify-signature.js +0 -198
  23. package/dist/oclif/api-command.js +0 -755
  24. package/dist/oclif/auth.js +0 -223
  25. package/dist/oclif/commands/emails-latest.js +0 -185
  26. package/dist/oclif/commands/emails-poll.js +0 -121
  27. package/dist/oclif/commands/emails-wait.js +0 -171
  28. package/dist/oclif/commands/emails-watch.js +0 -165
  29. package/dist/oclif/commands/functions-deploy.js +0 -124
  30. package/dist/oclif/commands/functions-init.js +0 -256
  31. package/dist/oclif/commands/functions-redeploy.js +0 -113
  32. package/dist/oclif/commands/functions-set-secret.js +0 -213
  33. package/dist/oclif/commands/login.js +0 -237
  34. package/dist/oclif/commands/logout.js +0 -88
  35. package/dist/oclif/commands/send.js +0 -222
  36. package/dist/oclif/commands/whoami.js +0 -95
  37. package/dist/oclif/fish-completion.js +0 -87
  38. package/dist/oclif/index.js +0 -167
  39. package/dist/oclif/lint/raw-send-mail-fetch.js +0 -98
  40. package/dist/openapi/openapi.generated.js +0 -5754
  41. package/dist/openapi/operations.generated.js +0 -4626
  42. package/dist/parser/address-parser.js +0 -129
  43. package/dist/types.generated.js +0 -7
  44. package/dist/types.js +0 -53
  45. package/dist/webhook/errors.js +0 -224
  46. package/dist/webhook/received-email.js +0 -82
  47. package/oclif.manifest.json +0 -4380
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primitivedotdev/sdk",
3
- "version": "0.26.0",
4
- "description": "Official Primitive Node.js SDK: webhook, api, openapi, contract, and parser runtime modules. The CLI moved to @primitivedotdev/cli; this package retains the CLI as a deprecated alias for a few minor releases.",
3
+ "version": "0.27.0",
4
+ "description": "Official Primitive Node.js SDK: webhook, api, openapi, contract, and parser runtime modules.",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -39,56 +39,8 @@
39
39
  },
40
40
  "sideEffects": false,
41
41
  "files": [
42
- "bin",
43
- "dist",
44
- "oclif.manifest.json"
42
+ "dist"
45
43
  ],
46
- "bin": {
47
- "primitive": "./bin/run.js"
48
- },
49
- "oclif": {
50
- "bin": "primitive",
51
- "commands": {
52
- "strategy": "explicit",
53
- "target": "./dist/oclif/index.js",
54
- "identifier": "COMMANDS"
55
- },
56
- "dirname": "primitive",
57
- "plugins": [
58
- "@oclif/plugin-help",
59
- "@oclif/plugin-autocomplete"
60
- ],
61
- "topics": {
62
- "cli": {
63
- "description": "Browser-assisted CLI authentication"
64
- },
65
- "account": {
66
- "description": "Manage your account settings, storage, and webhook secret"
67
- },
68
- "domains": {
69
- "description": "Claim, verify, and manage email domains"
70
- },
71
- "emails": {
72
- "description": "List, inspect, and manage received emails. Use `primitive emails:latest` for a one-line-per-email summary of recent inbound mail."
73
- },
74
- "sending": {
75
- "description": "Send outbound emails. For replies to inbound mail, use `sending:reply-to-email --id <inbound-id>` (threading and Re: subject derived server-side); for fresh sends, use `sending:send-email` or the `primitive send` shortcut."
76
- },
77
- "endpoints": {
78
- "description": "Manage webhook endpoints that receive email events"
79
- },
80
- "filters": {
81
- "description": "Manage whitelist and blocklist filter rules"
82
- },
83
- "webhook-deliveries": {
84
- "description": "View and replay webhook delivery attempts"
85
- },
86
- "functions": {
87
- "description": "Deploy JavaScript handlers that run on inbound mail. Use `primitive functions:init <name>` to scaffold a deployable project (handler, package.json, build script). Use `primitive functions:deploy --name <name> --file <bundle.js>` to create, `primitive functions:redeploy --id <id> --file <bundle.js>` to push a new bundle, and `primitive functions:set-secret --id <id> --key <KEY> --value <value> [--redeploy]` to write a secret (with optional one-call redeploy so the value lands in the running handler). The auto-generated functions:create-function / functions:update-function / functions:create-function-secret / functions:set-function-secret operations stay available for the full body-string surface."
88
- }
89
- },
90
- "topicSeparator": " "
91
- },
92
44
  "scripts": {
93
45
  "generate:openapi": "tsx scripts/generate-openapi-artifacts.ts",
94
46
  "generate:api": "openapi-ts -f openapi-ts.config.ts && tsx scripts/fix-generated-api-imports.ts",
@@ -96,17 +48,13 @@
96
48
  "generate:types": "tsx scripts/generate-types.ts",
97
49
  "generate:validator": "tsx scripts/generate-validator.ts",
98
50
  "generate": "pnpm generate:openapi && pnpm generate:api && pnpm generate:schema && pnpm generate:types && pnpm generate:validator",
99
- "build:library": "pnpm generate && tsdown",
100
- "build:oclif": "tsc -p tsconfig.oclif.json",
101
- "build": "pnpm build:library && pnpm build:oclif",
51
+ "build": "pnpm generate && tsdown",
102
52
  "test": "vitest run",
103
53
  "test:coverage": "vitest run --coverage",
104
54
  "test:watch": "vitest",
105
55
  "typecheck": "pnpm generate && tsc --noEmit -p tsconfig.typecheck.json",
106
- "lint": "biome check --error-on-warnings src/index.ts src/validation.ts src/types.ts src/webhook src/contract src/parser src/api/index.ts src/openapi/index.ts src/oclif tests/",
107
- "lint:fix": "biome check --write --error-on-warnings src/index.ts src/validation.ts src/types.ts src/webhook src/contract src/parser src/api/index.ts src/openapi/index.ts src/oclif tests/",
108
- "prepack": "pnpm build && oclif manifest",
109
- "postpack": "shx rm -f oclif.manifest.json",
56
+ "lint": "biome check --error-on-warnings src/index.ts src/validation.ts src/types.ts src/webhook src/contract src/parser src/api/index.ts src/openapi/index.ts tests/",
57
+ "lint:fix": "biome check --write --error-on-warnings src/index.ts src/validation.ts src/types.ts src/webhook src/contract src/parser src/api/index.ts src/openapi/index.ts tests/",
110
58
  "prepublishOnly": "pnpm build"
111
59
  },
112
60
  "keywords": [
@@ -135,9 +83,6 @@
135
83
  "node": ">=22"
136
84
  },
137
85
  "dependencies": {
138
- "@oclif/core": "^4.10.5",
139
- "@oclif/plugin-autocomplete": "^3.2.45",
140
- "@oclif/plugin-help": "^6.2.44",
141
86
  "ajv": "^8.17.1",
142
87
  "isomorphic-dompurify": "^3.8.0",
143
88
  "mailparser": "^3.9.0",
@@ -156,8 +101,6 @@
156
101
  "@types/validator": "^13.15.10",
157
102
  "@vitest/coverage-v8": "^4.1.4",
158
103
  "json-schema-to-typescript": "^15.0.4",
159
- "oclif": "^4.23.0",
160
- "shx": "^0.3.4",
161
104
  "tsdown": "^0.21.10",
162
105
  "tsx": "^4.21.0",
163
106
  "typescript": "^5.7.2",
package/bin/run.js DELETED
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // The CLI moved to @primitivedotdev/cli. This bin is retained on
4
- // @primitivedotdev/sdk for a few minor versions so existing scripts
5
- // and agent prompts that invoke `npx @primitivedotdev/sdk@latest
6
- // <command>` keep working. Every invocation prints a one-line stderr
7
- // banner with the migration command; the actual oclif runtime runs
8
- // unchanged after that. The CLI surface will be removed from
9
- // @primitivedotdev/sdk in a future minor release; until then this
10
- // shipped snapshot is frozen against the 0.23.0 command set.
11
- import { execute } from "@oclif/core";
12
-
13
- process.stderr.write(
14
- "[@primitivedotdev/sdk] Heads up: the CLI moved to @primitivedotdev/cli. " +
15
- "Switch to `npx @primitivedotdev/cli@latest <command>` " +
16
- "(or `npm install -g @primitivedotdev/cli`). " +
17
- "The CLI surface will be removed from @primitivedotdev/sdk in a future minor release.\n",
18
- );
19
-
20
- await execute({ dir: import.meta.url });
@@ -1,235 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
- import { createSseClient } from '../core/serverSentEvents.gen.js';
3
- import { getValidRequestBody } from '../core/utils.gen.js';
4
- import { buildUrl, createConfig, createInterceptors, getParseAs, mergeConfigs, mergeHeaders, setAuthParams, } from './utils.gen.js';
5
- export const createClient = (config = {}) => {
6
- let _config = mergeConfigs(createConfig(), config);
7
- const getConfig = () => ({ ..._config });
8
- const setConfig = (config) => {
9
- _config = mergeConfigs(_config, config);
10
- return getConfig();
11
- };
12
- const interceptors = createInterceptors();
13
- const beforeRequest = async (options) => {
14
- const opts = {
15
- ..._config,
16
- ...options,
17
- fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
18
- headers: mergeHeaders(_config.headers, options.headers),
19
- serializedBody: undefined,
20
- };
21
- if (opts.security) {
22
- await setAuthParams({
23
- ...opts,
24
- security: opts.security,
25
- });
26
- }
27
- if (opts.requestValidator) {
28
- await opts.requestValidator(opts);
29
- }
30
- if (opts.body !== undefined && opts.bodySerializer) {
31
- opts.serializedBody = opts.bodySerializer(opts.body);
32
- }
33
- // remove Content-Type header if body is empty to avoid sending invalid requests
34
- if (opts.body === undefined || opts.serializedBody === '') {
35
- opts.headers.delete('Content-Type');
36
- }
37
- const resolvedOpts = opts;
38
- const url = buildUrl(resolvedOpts);
39
- return { opts: resolvedOpts, url };
40
- };
41
- const request = async (options) => {
42
- const { opts, url } = await beforeRequest(options);
43
- const requestInit = {
44
- redirect: 'follow',
45
- ...opts,
46
- body: getValidRequestBody(opts),
47
- };
48
- let request = new Request(url, requestInit);
49
- for (const fn of interceptors.request.fns) {
50
- if (fn) {
51
- request = await fn(request, opts);
52
- }
53
- }
54
- // fetch must be assigned here, otherwise it would throw the error:
55
- // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
56
- const _fetch = opts.fetch;
57
- let response;
58
- try {
59
- response = await _fetch(request);
60
- }
61
- catch (error) {
62
- // Handle fetch exceptions (AbortError, network errors, etc.)
63
- let finalError = error;
64
- for (const fn of interceptors.error.fns) {
65
- if (fn) {
66
- finalError = (await fn(error, undefined, request, opts));
67
- }
68
- }
69
- finalError = finalError || {};
70
- if (opts.throwOnError) {
71
- throw finalError;
72
- }
73
- // Return error response
74
- return opts.responseStyle === 'data'
75
- ? undefined
76
- : {
77
- error: finalError,
78
- request,
79
- response: undefined,
80
- };
81
- }
82
- for (const fn of interceptors.response.fns) {
83
- if (fn) {
84
- response = await fn(response, request, opts);
85
- }
86
- }
87
- const result = {
88
- request,
89
- response,
90
- };
91
- if (response.ok) {
92
- const parseAs = (opts.parseAs === 'auto'
93
- ? getParseAs(response.headers.get('Content-Type'))
94
- : opts.parseAs) ?? 'json';
95
- if (response.status === 204 || response.headers.get('Content-Length') === '0') {
96
- let emptyData;
97
- switch (parseAs) {
98
- case 'arrayBuffer':
99
- case 'blob':
100
- case 'text':
101
- emptyData = await response[parseAs]();
102
- break;
103
- case 'formData':
104
- emptyData = new FormData();
105
- break;
106
- case 'stream':
107
- emptyData = response.body;
108
- break;
109
- case 'json':
110
- default:
111
- emptyData = {};
112
- break;
113
- }
114
- return opts.responseStyle === 'data'
115
- ? emptyData
116
- : {
117
- data: emptyData,
118
- ...result,
119
- };
120
- }
121
- let data;
122
- switch (parseAs) {
123
- case 'arrayBuffer':
124
- case 'blob':
125
- case 'formData':
126
- case 'text':
127
- data = await response[parseAs]();
128
- break;
129
- case 'json': {
130
- // Some servers return 200 with no Content-Length and empty body.
131
- // response.json() would throw; read as text and parse if non-empty.
132
- const text = await response.text();
133
- data = text ? JSON.parse(text) : {};
134
- break;
135
- }
136
- case 'stream':
137
- return opts.responseStyle === 'data'
138
- ? response.body
139
- : {
140
- data: response.body,
141
- ...result,
142
- };
143
- }
144
- if (parseAs === 'json') {
145
- if (opts.responseValidator) {
146
- await opts.responseValidator(data);
147
- }
148
- if (opts.responseTransformer) {
149
- data = await opts.responseTransformer(data);
150
- }
151
- }
152
- return opts.responseStyle === 'data'
153
- ? data
154
- : {
155
- data,
156
- ...result,
157
- };
158
- }
159
- const textError = await response.text();
160
- let jsonError;
161
- try {
162
- jsonError = JSON.parse(textError);
163
- }
164
- catch {
165
- // noop
166
- }
167
- const error = jsonError ?? textError;
168
- let finalError = error;
169
- for (const fn of interceptors.error.fns) {
170
- if (fn) {
171
- finalError = (await fn(error, response, request, opts));
172
- }
173
- }
174
- finalError = finalError || {};
175
- if (opts.throwOnError) {
176
- throw finalError;
177
- }
178
- // TODO: we probably want to return error and improve types
179
- return opts.responseStyle === 'data'
180
- ? undefined
181
- : {
182
- error: finalError,
183
- ...result,
184
- };
185
- };
186
- const makeMethodFn = (method) => (options) => request({ ...options, method });
187
- const makeSseFn = (method) => async (options) => {
188
- const { opts, url } = await beforeRequest(options);
189
- return createSseClient({
190
- ...opts,
191
- body: opts.body,
192
- headers: opts.headers,
193
- method,
194
- onRequest: async (url, init) => {
195
- let request = new Request(url, init);
196
- for (const fn of interceptors.request.fns) {
197
- if (fn) {
198
- request = await fn(request, opts);
199
- }
200
- }
201
- return request;
202
- },
203
- serializedBody: getValidRequestBody(opts),
204
- url,
205
- });
206
- };
207
- const _buildUrl = (options) => buildUrl({ ..._config, ...options });
208
- return {
209
- buildUrl: _buildUrl,
210
- connect: makeMethodFn('CONNECT'),
211
- delete: makeMethodFn('DELETE'),
212
- get: makeMethodFn('GET'),
213
- getConfig,
214
- head: makeMethodFn('HEAD'),
215
- interceptors,
216
- options: makeMethodFn('OPTIONS'),
217
- patch: makeMethodFn('PATCH'),
218
- post: makeMethodFn('POST'),
219
- put: makeMethodFn('PUT'),
220
- request,
221
- setConfig,
222
- sse: {
223
- connect: makeSseFn('CONNECT'),
224
- delete: makeSseFn('DELETE'),
225
- get: makeSseFn('GET'),
226
- head: makeSseFn('HEAD'),
227
- options: makeSseFn('OPTIONS'),
228
- patch: makeSseFn('PATCH'),
229
- post: makeSseFn('POST'),
230
- put: makeSseFn('PUT'),
231
- trace: makeSseFn('TRACE'),
232
- },
233
- trace: makeMethodFn('TRACE'),
234
- };
235
- };
@@ -1,6 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
- export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, } from '../core/bodySerializer.gen.js';
3
- export { buildClientParams } from '../core/params.gen.js';
4
- export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen.js';
5
- export { createClient } from './client.gen.js';
6
- export { createConfig, mergeHeaders } from './utils.gen.js';
@@ -1,2 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
- export {};
@@ -1,228 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
- import { getAuthToken } from '../core/auth.gen.js';
3
- import { jsonBodySerializer } from '../core/bodySerializer.gen.js';
4
- import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam, } from '../core/pathSerializer.gen.js';
5
- import { getUrl } from '../core/utils.gen.js';
6
- export const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
7
- const querySerializer = (queryParams) => {
8
- const search = [];
9
- if (queryParams && typeof queryParams === 'object') {
10
- for (const name in queryParams) {
11
- const value = queryParams[name];
12
- if (value === undefined || value === null) {
13
- continue;
14
- }
15
- const options = parameters[name] || args;
16
- if (Array.isArray(value)) {
17
- const serializedArray = serializeArrayParam({
18
- allowReserved: options.allowReserved,
19
- explode: true,
20
- name,
21
- style: 'form',
22
- value,
23
- ...options.array,
24
- });
25
- if (serializedArray)
26
- search.push(serializedArray);
27
- }
28
- else if (typeof value === 'object') {
29
- const serializedObject = serializeObjectParam({
30
- allowReserved: options.allowReserved,
31
- explode: true,
32
- name,
33
- style: 'deepObject',
34
- value: value,
35
- ...options.object,
36
- });
37
- if (serializedObject)
38
- search.push(serializedObject);
39
- }
40
- else {
41
- const serializedPrimitive = serializePrimitiveParam({
42
- allowReserved: options.allowReserved,
43
- name,
44
- value: value,
45
- });
46
- if (serializedPrimitive)
47
- search.push(serializedPrimitive);
48
- }
49
- }
50
- }
51
- return search.join('&');
52
- };
53
- return querySerializer;
54
- };
55
- /**
56
- * Infers parseAs value from provided Content-Type header.
57
- */
58
- export const getParseAs = (contentType) => {
59
- if (!contentType) {
60
- // If no Content-Type header is provided, the best we can do is return the raw response body,
61
- // which is effectively the same as the 'stream' option.
62
- return 'stream';
63
- }
64
- const cleanContent = contentType.split(';')[0]?.trim();
65
- if (!cleanContent) {
66
- return;
67
- }
68
- if (cleanContent.startsWith('application/json') || cleanContent.endsWith('+json')) {
69
- return 'json';
70
- }
71
- if (cleanContent === 'multipart/form-data') {
72
- return 'formData';
73
- }
74
- if (['application/', 'audio/', 'image/', 'video/'].some((type) => cleanContent.startsWith(type))) {
75
- return 'blob';
76
- }
77
- if (cleanContent.startsWith('text/')) {
78
- return 'text';
79
- }
80
- return;
81
- };
82
- const checkForExistence = (options, name) => {
83
- if (!name) {
84
- return false;
85
- }
86
- if (options.headers.has(name) ||
87
- options.query?.[name] ||
88
- options.headers.get('Cookie')?.includes(`${name}=`)) {
89
- return true;
90
- }
91
- return false;
92
- };
93
- export const setAuthParams = async ({ security, ...options }) => {
94
- for (const auth of security) {
95
- if (checkForExistence(options, auth.name)) {
96
- continue;
97
- }
98
- const token = await getAuthToken(auth, options.auth);
99
- if (!token) {
100
- continue;
101
- }
102
- const name = auth.name ?? 'Authorization';
103
- switch (auth.in) {
104
- case 'query':
105
- if (!options.query) {
106
- options.query = {};
107
- }
108
- options.query[name] = token;
109
- break;
110
- case 'cookie':
111
- options.headers.append('Cookie', `${name}=${token}`);
112
- break;
113
- case 'header':
114
- default:
115
- options.headers.set(name, token);
116
- break;
117
- }
118
- }
119
- };
120
- export const buildUrl = (options) => getUrl({
121
- baseUrl: options.baseUrl,
122
- path: options.path,
123
- query: options.query,
124
- querySerializer: typeof options.querySerializer === 'function'
125
- ? options.querySerializer
126
- : createQuerySerializer(options.querySerializer),
127
- url: options.url,
128
- });
129
- export const mergeConfigs = (a, b) => {
130
- const config = { ...a, ...b };
131
- if (config.baseUrl?.endsWith('/')) {
132
- config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
133
- }
134
- config.headers = mergeHeaders(a.headers, b.headers);
135
- return config;
136
- };
137
- const headersEntries = (headers) => {
138
- const entries = [];
139
- headers.forEach((value, key) => {
140
- entries.push([key, value]);
141
- });
142
- return entries;
143
- };
144
- export const mergeHeaders = (...headers) => {
145
- const mergedHeaders = new Headers();
146
- for (const header of headers) {
147
- if (!header) {
148
- continue;
149
- }
150
- const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
151
- for (const [key, value] of iterator) {
152
- if (value === null) {
153
- mergedHeaders.delete(key);
154
- }
155
- else if (Array.isArray(value)) {
156
- for (const v of value) {
157
- mergedHeaders.append(key, v);
158
- }
159
- }
160
- else if (value !== undefined) {
161
- // assume object headers are meant to be JSON stringified, i.e., their
162
- // content value in OpenAPI specification is 'application/json'
163
- mergedHeaders.set(key, typeof value === 'object' ? JSON.stringify(value) : value);
164
- }
165
- }
166
- }
167
- return mergedHeaders;
168
- };
169
- class Interceptors {
170
- fns = [];
171
- clear() {
172
- this.fns = [];
173
- }
174
- eject(id) {
175
- const index = this.getInterceptorIndex(id);
176
- if (this.fns[index]) {
177
- this.fns[index] = null;
178
- }
179
- }
180
- exists(id) {
181
- const index = this.getInterceptorIndex(id);
182
- return Boolean(this.fns[index]);
183
- }
184
- getInterceptorIndex(id) {
185
- if (typeof id === 'number') {
186
- return this.fns[id] ? id : -1;
187
- }
188
- return this.fns.indexOf(id);
189
- }
190
- update(id, fn) {
191
- const index = this.getInterceptorIndex(id);
192
- if (this.fns[index]) {
193
- this.fns[index] = fn;
194
- return id;
195
- }
196
- return false;
197
- }
198
- use(fn) {
199
- this.fns.push(fn);
200
- return this.fns.length - 1;
201
- }
202
- }
203
- export const createInterceptors = () => ({
204
- error: new Interceptors(),
205
- request: new Interceptors(),
206
- response: new Interceptors(),
207
- });
208
- const defaultQuerySerializer = createQuerySerializer({
209
- allowReserved: false,
210
- array: {
211
- explode: true,
212
- style: 'form',
213
- },
214
- object: {
215
- explode: true,
216
- style: 'deepObject',
217
- },
218
- });
219
- const defaultHeaders = {
220
- 'Content-Type': 'application/json',
221
- };
222
- export const createConfig = (override = {}) => ({
223
- ...jsonBodySerializer,
224
- headers: defaultHeaders,
225
- parseAs: 'auto',
226
- querySerializer: defaultQuerySerializer,
227
- ...override,
228
- });
@@ -1,3 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
- import { createClient, createConfig } from './client/index.js';
3
- export const client = createClient(createConfig({ baseUrl: 'https://www.primitive.dev/api/v1' }));
@@ -1,14 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
- export const getAuthToken = async (auth, callback) => {
3
- const token = typeof callback === 'function' ? await callback(auth) : callback;
4
- if (!token) {
5
- return;
6
- }
7
- if (auth.scheme === 'bearer') {
8
- return `Bearer ${token}`;
9
- }
10
- if (auth.scheme === 'basic') {
11
- return `Basic ${btoa(token)}`;
12
- }
13
- return token;
14
- };
@@ -1,57 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
- const serializeFormDataPair = (data, key, value) => {
3
- if (typeof value === 'string' || value instanceof Blob) {
4
- data.append(key, value);
5
- }
6
- else if (value instanceof Date) {
7
- data.append(key, value.toISOString());
8
- }
9
- else {
10
- data.append(key, JSON.stringify(value));
11
- }
12
- };
13
- const serializeUrlSearchParamsPair = (data, key, value) => {
14
- if (typeof value === 'string') {
15
- data.append(key, value);
16
- }
17
- else {
18
- data.append(key, JSON.stringify(value));
19
- }
20
- };
21
- export const formDataBodySerializer = {
22
- bodySerializer: (body) => {
23
- const data = new FormData();
24
- Object.entries(body).forEach(([key, value]) => {
25
- if (value === undefined || value === null) {
26
- return;
27
- }
28
- if (Array.isArray(value)) {
29
- value.forEach((v) => serializeFormDataPair(data, key, v));
30
- }
31
- else {
32
- serializeFormDataPair(data, key, value);
33
- }
34
- });
35
- return data;
36
- },
37
- };
38
- export const jsonBodySerializer = {
39
- bodySerializer: (body) => JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value)),
40
- };
41
- export const urlSearchParamsBodySerializer = {
42
- bodySerializer: (body) => {
43
- const data = new URLSearchParams();
44
- Object.entries(body).forEach(([key, value]) => {
45
- if (value === undefined || value === null) {
46
- return;
47
- }
48
- if (Array.isArray(value)) {
49
- value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
50
- }
51
- else {
52
- serializeUrlSearchParamsPair(data, key, value);
53
- }
54
- });
55
- return data.toString();
56
- },
57
- };