@crevio/sdk 0.4.2 → 0.4.8
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/commonjs/funcs/blogPostsGet.js.map +1 -1
- package/dist/commonjs/funcs/cartsDelete.js.map +1 -1
- package/dist/commonjs/funcs/cartsGet.js.map +1 -1
- package/dist/commonjs/funcs/cartsUpdate.js.map +1 -1
- package/dist/commonjs/funcs/checkoutLinksDelete.js.map +1 -1
- package/dist/commonjs/funcs/checkoutLinksGet.js.map +1 -1
- package/dist/commonjs/funcs/checkoutLinksUpdate.js.map +1 -1
- package/dist/commonjs/funcs/checkoutsGet.js.map +1 -1
- package/dist/commonjs/funcs/checkoutsUpdate.js.map +1 -1
- package/dist/commonjs/funcs/customersGet.js.map +1 -1
- package/dist/commonjs/funcs/customersUpdate.js.map +1 -1
- package/dist/commonjs/funcs/discountsDelete.js.map +1 -1
- package/dist/commonjs/funcs/discountsGet.js.map +1 -1
- package/dist/commonjs/funcs/discountsUpdate.js.map +1 -1
- package/dist/commonjs/funcs/experiencesGet.js.map +1 -1
- package/dist/commonjs/funcs/filesDelete.js.map +1 -1
- package/dist/commonjs/funcs/filesGet.js.map +1 -1
- package/dist/commonjs/funcs/invoicesGet.js.map +1 -1
- package/dist/commonjs/funcs/invoicesPay.js.map +1 -1
- package/dist/commonjs/funcs/invoicesVoid.js.map +1 -1
- package/dist/commonjs/funcs/orderItemsGet.js.map +1 -1
- package/dist/commonjs/funcs/ordersGet.js.map +1 -1
- package/dist/commonjs/funcs/priceVariantsGet.js.map +1 -1
- package/dist/commonjs/funcs/priceVariantsUpdate.js.map +1 -1
- package/dist/commonjs/funcs/productsDelete.js.map +1 -1
- package/dist/commonjs/funcs/productsGet.js.map +1 -1
- package/dist/commonjs/funcs/productsRequestX402Access.js.map +1 -1
- package/dist/commonjs/funcs/productsUpdate.js.map +1 -1
- package/dist/commonjs/funcs/reviewsGet.js.map +1 -1
- package/dist/commonjs/funcs/subscriptionsCancel.js.map +1 -1
- package/dist/commonjs/funcs/subscriptionsGet.js.map +1 -1
- package/dist/commonjs/funcs/subscriptionsPause.js.map +1 -1
- package/dist/commonjs/funcs/subscriptionsResume.js.map +1 -1
- package/dist/commonjs/funcs/webhookEndpointsDelete.js.map +1 -1
- package/dist/commonjs/funcs/webhookEndpointsGet.js.map +1 -1
- package/dist/commonjs/funcs/webhookEndpointsTest.js.map +1 -1
- package/dist/commonjs/funcs/webhookEndpointsUpdate.js.map +1 -1
- package/dist/commonjs/lib/config.d.ts +3 -3
- package/dist/commonjs/lib/config.js +3 -3
- package/dist/commonjs/lib/files.d.ts +13 -0
- package/dist/commonjs/lib/files.d.ts.map +1 -1
- package/dist/commonjs/lib/files.js +19 -0
- package/dist/commonjs/lib/files.js.map +1 -1
- package/dist/commonjs/lib/sdks.d.ts.map +1 -1
- package/dist/commonjs/lib/sdks.js +8 -4
- package/dist/commonjs/lib/sdks.js.map +1 -1
- package/dist/commonjs/lib/url.d.ts.map +1 -1
- package/dist/commonjs/lib/url.js +4 -2
- package/dist/commonjs/lib/url.js.map +1 -1
- package/dist/commonjs/models/account.d.ts +7 -0
- package/dist/commonjs/models/account.d.ts.map +1 -1
- package/dist/commonjs/models/account.js +15 -0
- package/dist/commonjs/models/account.js.map +1 -1
- package/dist/commonjs/models/blogpost.d.ts +1 -1
- package/dist/commonjs/models/blogpost.d.ts.map +1 -1
- package/dist/commonjs/models/blogpost.js +1 -1
- package/dist/commonjs/models/blogpost.js.map +1 -1
- package/dist/commonjs/models/index.d.ts +3 -0
- package/dist/commonjs/models/index.d.ts.map +1 -1
- package/dist/commonjs/models/index.js +3 -0
- package/dist/commonjs/models/index.js.map +1 -1
- package/dist/commonjs/models/mediagalleryitem.d.ts +12 -0
- package/dist/commonjs/models/mediagalleryitem.d.ts.map +1 -0
- package/dist/commonjs/models/mediagalleryitem.js +52 -0
- package/dist/commonjs/models/mediagalleryitem.js.map +1 -0
- package/dist/commonjs/models/pricevariant.d.ts +7 -1
- package/dist/commonjs/models/pricevariant.d.ts.map +1 -1
- package/dist/commonjs/models/pricevariant.js +12 -2
- package/dist/commonjs/models/pricevariant.js.map +1 -1
- package/dist/commonjs/models/product.d.ts +21 -0
- package/dist/commonjs/models/product.d.ts.map +1 -1
- package/dist/commonjs/models/product.js +26 -1
- package/dist/commonjs/models/product.js.map +1 -1
- package/dist/commonjs/models/review.d.ts +1 -0
- package/dist/commonjs/models/review.d.ts.map +1 -1
- package/dist/commonjs/models/review.js +2 -0
- package/dist/commonjs/models/review.js.map +1 -1
- package/dist/commonjs/models/seo.d.ts +11 -0
- package/dist/commonjs/models/seo.d.ts.map +1 -0
- package/dist/commonjs/models/seo.js +52 -0
- package/dist/commonjs/models/seo.js.map +1 -0
- package/dist/commonjs/models/sociallink.d.ts +29 -0
- package/dist/commonjs/models/sociallink.d.ts.map +1 -0
- package/dist/commonjs/models/sociallink.js +68 -0
- package/dist/commonjs/models/sociallink.js.map +1 -0
- package/dist/esm/funcs/blogPostsGet.js.map +1 -1
- package/dist/esm/funcs/cartsDelete.js.map +1 -1
- package/dist/esm/funcs/cartsGet.js.map +1 -1
- package/dist/esm/funcs/cartsUpdate.js.map +1 -1
- package/dist/esm/funcs/checkoutLinksDelete.js.map +1 -1
- package/dist/esm/funcs/checkoutLinksGet.js.map +1 -1
- package/dist/esm/funcs/checkoutLinksUpdate.js.map +1 -1
- package/dist/esm/funcs/checkoutsGet.js.map +1 -1
- package/dist/esm/funcs/checkoutsUpdate.js.map +1 -1
- package/dist/esm/funcs/customersGet.js.map +1 -1
- package/dist/esm/funcs/customersUpdate.js.map +1 -1
- package/dist/esm/funcs/discountsDelete.js.map +1 -1
- package/dist/esm/funcs/discountsGet.js.map +1 -1
- package/dist/esm/funcs/discountsUpdate.js.map +1 -1
- package/dist/esm/funcs/experiencesGet.js.map +1 -1
- package/dist/esm/funcs/filesDelete.js.map +1 -1
- package/dist/esm/funcs/filesGet.js.map +1 -1
- package/dist/esm/funcs/invoicesGet.js.map +1 -1
- package/dist/esm/funcs/invoicesPay.js.map +1 -1
- package/dist/esm/funcs/invoicesVoid.js.map +1 -1
- package/dist/esm/funcs/orderItemsGet.js.map +1 -1
- package/dist/esm/funcs/ordersGet.js.map +1 -1
- package/dist/esm/funcs/priceVariantsGet.js.map +1 -1
- package/dist/esm/funcs/priceVariantsUpdate.js.map +1 -1
- package/dist/esm/funcs/productsDelete.js.map +1 -1
- package/dist/esm/funcs/productsGet.js.map +1 -1
- package/dist/esm/funcs/productsRequestX402Access.js.map +1 -1
- package/dist/esm/funcs/productsUpdate.js.map +1 -1
- package/dist/esm/funcs/reviewsGet.js.map +1 -1
- package/dist/esm/funcs/subscriptionsCancel.js.map +1 -1
- package/dist/esm/funcs/subscriptionsGet.js.map +1 -1
- package/dist/esm/funcs/subscriptionsPause.js.map +1 -1
- package/dist/esm/funcs/subscriptionsResume.js.map +1 -1
- package/dist/esm/funcs/webhookEndpointsDelete.js.map +1 -1
- package/dist/esm/funcs/webhookEndpointsGet.js.map +1 -1
- package/dist/esm/funcs/webhookEndpointsTest.js.map +1 -1
- package/dist/esm/funcs/webhookEndpointsUpdate.js.map +1 -1
- package/dist/esm/lib/config.d.ts +3 -3
- package/dist/esm/lib/config.js +3 -3
- package/dist/esm/lib/files.d.ts +13 -0
- package/dist/esm/lib/files.d.ts.map +1 -1
- package/dist/esm/lib/files.js +18 -0
- package/dist/esm/lib/files.js.map +1 -1
- package/dist/esm/lib/sdks.d.ts.map +1 -1
- package/dist/esm/lib/sdks.js +8 -4
- package/dist/esm/lib/sdks.js.map +1 -1
- package/dist/esm/lib/url.d.ts.map +1 -1
- package/dist/esm/lib/url.js +4 -2
- package/dist/esm/lib/url.js.map +1 -1
- package/dist/esm/models/account.d.ts +7 -0
- package/dist/esm/models/account.d.ts.map +1 -1
- package/dist/esm/models/account.js +15 -0
- package/dist/esm/models/account.js.map +1 -1
- package/dist/esm/models/blogpost.d.ts +1 -1
- package/dist/esm/models/blogpost.d.ts.map +1 -1
- package/dist/esm/models/blogpost.js +1 -1
- package/dist/esm/models/blogpost.js.map +1 -1
- package/dist/esm/models/index.d.ts +3 -0
- package/dist/esm/models/index.d.ts.map +1 -1
- package/dist/esm/models/index.js +3 -0
- package/dist/esm/models/index.js.map +1 -1
- package/dist/esm/models/mediagalleryitem.d.ts +12 -0
- package/dist/esm/models/mediagalleryitem.d.ts.map +1 -0
- package/dist/esm/models/mediagalleryitem.js +15 -0
- package/dist/esm/models/mediagalleryitem.js.map +1 -0
- package/dist/esm/models/pricevariant.d.ts +7 -1
- package/dist/esm/models/pricevariant.d.ts.map +1 -1
- package/dist/esm/models/pricevariant.js +12 -2
- package/dist/esm/models/pricevariant.js.map +1 -1
- package/dist/esm/models/product.d.ts +21 -0
- package/dist/esm/models/product.d.ts.map +1 -1
- package/dist/esm/models/product.js +24 -0
- package/dist/esm/models/product.js.map +1 -1
- package/dist/esm/models/review.d.ts +1 -0
- package/dist/esm/models/review.d.ts.map +1 -1
- package/dist/esm/models/review.js +2 -0
- package/dist/esm/models/review.js.map +1 -1
- package/dist/esm/models/seo.d.ts +11 -0
- package/dist/esm/models/seo.d.ts.map +1 -0
- package/dist/esm/models/seo.js +15 -0
- package/dist/esm/models/seo.js.map +1 -0
- package/dist/esm/models/sociallink.d.ts +29 -0
- package/dist/esm/models/sociallink.d.ts.map +1 -0
- package/dist/esm/models/sociallink.js +31 -0
- package/dist/esm/models/sociallink.js.map +1 -0
- package/jsr.json +1 -1
- package/package.json +2 -1
- package/src/funcs/blogPostsGet.ts +0 -1
- package/src/funcs/cartsDelete.ts +0 -1
- package/src/funcs/cartsGet.ts +0 -1
- package/src/funcs/cartsUpdate.ts +0 -1
- package/src/funcs/checkoutLinksDelete.ts +0 -1
- package/src/funcs/checkoutLinksGet.ts +0 -1
- package/src/funcs/checkoutLinksUpdate.ts +0 -1
- package/src/funcs/checkoutsGet.ts +0 -1
- package/src/funcs/checkoutsUpdate.ts +0 -1
- package/src/funcs/customersGet.ts +0 -1
- package/src/funcs/customersUpdate.ts +0 -1
- package/src/funcs/discountsDelete.ts +0 -1
- package/src/funcs/discountsGet.ts +0 -1
- package/src/funcs/discountsUpdate.ts +0 -1
- package/src/funcs/experiencesGet.ts +0 -1
- package/src/funcs/filesDelete.ts +0 -1
- package/src/funcs/filesGet.ts +0 -1
- package/src/funcs/invoicesGet.ts +0 -1
- package/src/funcs/invoicesPay.ts +0 -1
- package/src/funcs/invoicesVoid.ts +0 -1
- package/src/funcs/orderItemsGet.ts +0 -1
- package/src/funcs/ordersGet.ts +0 -1
- package/src/funcs/priceVariantsGet.ts +0 -1
- package/src/funcs/priceVariantsUpdate.ts +0 -1
- package/src/funcs/productsDelete.ts +0 -1
- package/src/funcs/productsGet.ts +0 -1
- package/src/funcs/productsRequestX402Access.ts +0 -1
- package/src/funcs/productsUpdate.ts +0 -1
- package/src/funcs/reviewsGet.ts +0 -1
- package/src/funcs/subscriptionsCancel.ts +0 -1
- package/src/funcs/subscriptionsGet.ts +0 -1
- package/src/funcs/subscriptionsPause.ts +0 -1
- package/src/funcs/subscriptionsResume.ts +0 -1
- package/src/funcs/webhookEndpointsDelete.ts +0 -1
- package/src/funcs/webhookEndpointsGet.ts +0 -1
- package/src/funcs/webhookEndpointsTest.ts +0 -1
- package/src/funcs/webhookEndpointsUpdate.ts +0 -1
- package/src/lib/config.ts +3 -3
- package/src/lib/files.ts +22 -0
- package/src/lib/sdks.ts +7 -5
- package/src/lib/url.ts +16 -14
- package/src/models/account.ts +21 -0
- package/src/models/blogpost.ts +2 -2
- package/src/models/index.ts +3 -0
- package/src/models/mediagalleryitem.ts +35 -0
- package/src/models/pricevariant.ts +19 -3
- package/src/models/product.ts +62 -0
- package/src/models/review.ts +3 -0
- package/src/models/seo.ts +30 -0
- package/src/models/sociallink.ts +54 -0
- package/test-sdk.ts +0 -74
package/src/lib/config.ts
CHANGED
|
@@ -61,7 +61,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
|
61
61
|
export const SDK_METADATA = {
|
|
62
62
|
language: "typescript",
|
|
63
63
|
openapiDocVersion: "1.0.0",
|
|
64
|
-
sdkVersion: "0.4.
|
|
65
|
-
genVersion: "2.
|
|
66
|
-
userAgent: "speakeasy-sdk/typescript 0.4.
|
|
64
|
+
sdkVersion: "0.4.8",
|
|
65
|
+
genVersion: "2.869.3",
|
|
66
|
+
userAgent: "speakeasy-sdk/typescript 0.4.8 2.869.3 1.0.0 @crevio/sdk",
|
|
67
67
|
} as const;
|
package/src/lib/files.ts
CHANGED
|
@@ -80,3 +80,25 @@ export function getContentTypeFromFileName(fileName: string): string | null {
|
|
|
80
80
|
|
|
81
81
|
return mimeTypes[ext] || null;
|
|
82
82
|
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Creates a Blob from file content with the given MIME type.
|
|
86
|
+
*
|
|
87
|
+
* Node.js Buffers are Uint8Array subclasses that may share a pooled
|
|
88
|
+
* ArrayBuffer (byteOffset > 0, byteLength < buffer.byteLength). Passing
|
|
89
|
+
* such a Buffer directly to `new Blob([buf])` can include the entire
|
|
90
|
+
* underlying pool on some runtimes, producing a Blob with extra bytes
|
|
91
|
+
* that corrupts multipart uploads.
|
|
92
|
+
*
|
|
93
|
+
* Copying into a standalone Uint8Array ensures the Blob receives only the
|
|
94
|
+
* intended bytes regardless of runtime behaviour.
|
|
95
|
+
*/
|
|
96
|
+
export function bytesToBlob(
|
|
97
|
+
content: Uint8Array<ArrayBufferLike> | ArrayBuffer | Blob | string,
|
|
98
|
+
contentType: string,
|
|
99
|
+
): Blob {
|
|
100
|
+
if (content instanceof Uint8Array) {
|
|
101
|
+
return new Blob([new Uint8Array(content)], { type: contentType });
|
|
102
|
+
}
|
|
103
|
+
return new Blob([content as BlobPart], { type: contentType });
|
|
104
|
+
}
|
package/src/lib/sdks.ts
CHANGED
|
@@ -127,13 +127,15 @@ export class ClientSDK {
|
|
|
127
127
|
if (!base) {
|
|
128
128
|
return ERR(new InvalidRequestError("No base URL provided for operation"));
|
|
129
129
|
}
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
const baseURL = new URL(base);
|
|
131
|
+
let reqURL: URL;
|
|
133
132
|
if (path) {
|
|
134
|
-
|
|
135
|
-
reqURL
|
|
133
|
+
baseURL.pathname = baseURL.pathname.replace(/\/+$/, "") + "/";
|
|
134
|
+
reqURL = new URL(path, baseURL);
|
|
135
|
+
} else {
|
|
136
|
+
reqURL = baseURL;
|
|
136
137
|
}
|
|
138
|
+
reqURL.hash = "";
|
|
137
139
|
|
|
138
140
|
let finalQuery = query || "";
|
|
139
141
|
|
package/src/lib/url.ts
CHANGED
|
@@ -13,21 +13,23 @@ export function pathToFunc(
|
|
|
13
13
|
const paramRE = /\{([a-zA-Z0-9_][a-zA-Z0-9_-]*?)\}/g;
|
|
14
14
|
|
|
15
15
|
return function buildURLPath(params: Record<string, unknown> = {}): string {
|
|
16
|
-
return pathPattern
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
return pathPattern
|
|
17
|
+
.replace(paramRE, function (_, placeholder) {
|
|
18
|
+
if (!hasOwn.call(params, placeholder)) {
|
|
19
|
+
throw new Error(`Parameter '${placeholder}' is required`);
|
|
20
|
+
}
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
const value = params[placeholder];
|
|
23
|
+
if (typeof value !== "string" && typeof value !== "number") {
|
|
24
|
+
throw new Error(
|
|
25
|
+
`Parameter '${placeholder}' must be a string or number`,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
return options?.charEncoding === "percent"
|
|
30
|
+
? encodeURIComponent(`${value}`)
|
|
31
|
+
: `${value}`;
|
|
32
|
+
})
|
|
33
|
+
.replace(/^\/+/, "");
|
|
32
34
|
};
|
|
33
35
|
}
|
package/src/models/account.ts
CHANGED
|
@@ -3,15 +3,23 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import * as z from "zod/v3";
|
|
6
|
+
import { remap as remap$ } from "../lib/primitives.js";
|
|
6
7
|
import { safeParse } from "../lib/schemas.js";
|
|
7
8
|
import { Result as SafeParseResult } from "../types/fp.js";
|
|
8
9
|
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
10
|
+
import { SocialLink, SocialLink$inboundSchema } from "./sociallink.js";
|
|
9
11
|
|
|
10
12
|
export type Account = {
|
|
11
13
|
id: string;
|
|
12
14
|
object: string;
|
|
13
15
|
name: string;
|
|
14
16
|
subdomain: string | null;
|
|
17
|
+
domain: string | null;
|
|
18
|
+
displayCurrency: string;
|
|
19
|
+
supportEmail: string | null;
|
|
20
|
+
avatarUrl: string | null;
|
|
21
|
+
description: string | null;
|
|
22
|
+
socialLinks: Array<SocialLink>;
|
|
15
23
|
};
|
|
16
24
|
|
|
17
25
|
/** @internal */
|
|
@@ -21,6 +29,19 @@ export const Account$inboundSchema: z.ZodType<Account, z.ZodTypeDef, unknown> =
|
|
|
21
29
|
object: z.string(),
|
|
22
30
|
name: z.string(),
|
|
23
31
|
subdomain: z.nullable(z.string()),
|
|
32
|
+
domain: z.nullable(z.string()),
|
|
33
|
+
display_currency: z.string(),
|
|
34
|
+
support_email: z.nullable(z.string()),
|
|
35
|
+
avatar_url: z.nullable(z.string()),
|
|
36
|
+
description: z.nullable(z.string()),
|
|
37
|
+
social_links: z.array(SocialLink$inboundSchema),
|
|
38
|
+
}).transform((v) => {
|
|
39
|
+
return remap$(v, {
|
|
40
|
+
"display_currency": "displayCurrency",
|
|
41
|
+
"support_email": "supportEmail",
|
|
42
|
+
"avatar_url": "avatarUrl",
|
|
43
|
+
"social_links": "socialLinks",
|
|
44
|
+
});
|
|
24
45
|
});
|
|
25
46
|
|
|
26
47
|
export function accountFromJSON(
|
package/src/models/blogpost.ts
CHANGED
|
@@ -29,7 +29,7 @@ export type BlogPost = {
|
|
|
29
29
|
createdAt: Date;
|
|
30
30
|
updatedAt: Date;
|
|
31
31
|
url: string;
|
|
32
|
-
category
|
|
32
|
+
category: string | null;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
/** @internal */
|
|
@@ -56,7 +56,7 @@ export const BlogPost$inboundSchema: z.ZodType<
|
|
|
56
56
|
created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)),
|
|
57
57
|
updated_at: z.string().datetime({ offset: true }).transform(v => new Date(v)),
|
|
58
58
|
url: z.string(),
|
|
59
|
-
category: z.
|
|
59
|
+
category: z.nullable(z.string()),
|
|
60
60
|
}).transform((v) => {
|
|
61
61
|
return remap$(v, {
|
|
62
62
|
"published_at": "publishedAt",
|
package/src/models/index.ts
CHANGED
|
@@ -39,6 +39,7 @@ export * from "./listresponsereview.js";
|
|
|
39
39
|
export * from "./listresponsesubscription.js";
|
|
40
40
|
export * from "./listresponsewebhookendpoint.js";
|
|
41
41
|
export * from "./me.js";
|
|
42
|
+
export * from "./mediagalleryitem.js";
|
|
42
43
|
export * from "./order.js";
|
|
43
44
|
export * from "./orderitem.js";
|
|
44
45
|
export * from "./pricevariant.js";
|
|
@@ -48,6 +49,8 @@ export * from "./product.js";
|
|
|
48
49
|
export * from "./productrequest.js";
|
|
49
50
|
export * from "./review.js";
|
|
50
51
|
export * from "./security.js";
|
|
52
|
+
export * from "./seo.js";
|
|
53
|
+
export * from "./sociallink.js";
|
|
51
54
|
export * from "./subscription.js";
|
|
52
55
|
export * from "./webhookendpoint.js";
|
|
53
56
|
export * from "./webhookendpointrequest.js";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { safeParse } from "../lib/schemas.js";
|
|
7
|
+
import { Result as SafeParseResult } from "../types/fp.js";
|
|
8
|
+
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
9
|
+
|
|
10
|
+
export type MediaGalleryItem = {
|
|
11
|
+
id: string;
|
|
12
|
+
type: string;
|
|
13
|
+
url: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** @internal */
|
|
17
|
+
export const MediaGalleryItem$inboundSchema: z.ZodType<
|
|
18
|
+
MediaGalleryItem,
|
|
19
|
+
z.ZodTypeDef,
|
|
20
|
+
unknown
|
|
21
|
+
> = z.object({
|
|
22
|
+
id: z.string(),
|
|
23
|
+
type: z.string(),
|
|
24
|
+
url: z.string(),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export function mediaGalleryItemFromJSON(
|
|
28
|
+
jsonString: string,
|
|
29
|
+
): SafeParseResult<MediaGalleryItem, SDKValidationError> {
|
|
30
|
+
return safeParse(
|
|
31
|
+
jsonString,
|
|
32
|
+
(x) => MediaGalleryItem$inboundSchema.parse(JSON.parse(x)),
|
|
33
|
+
`Failed to parse 'MediaGalleryItem' from JSON`,
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -52,8 +52,14 @@ export type PriceVariant = {
|
|
|
52
52
|
createdAt: Date;
|
|
53
53
|
updatedAt: Date;
|
|
54
54
|
currency: string | null;
|
|
55
|
+
discountedFromAmount: number | null;
|
|
56
|
+
minimumAmount: number | null;
|
|
57
|
+
maximumAmount: number | null;
|
|
58
|
+
presetAmount: number | null;
|
|
59
|
+
waitlist: boolean;
|
|
60
|
+
benefits?: Array<string> | undefined;
|
|
61
|
+
purchaseUrl: string;
|
|
55
62
|
product: string;
|
|
56
|
-
x402Amount: string;
|
|
57
63
|
};
|
|
58
64
|
|
|
59
65
|
/** @internal */
|
|
@@ -94,8 +100,14 @@ export const PriceVariant$inboundSchema: z.ZodType<
|
|
|
94
100
|
created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)),
|
|
95
101
|
updated_at: z.string().datetime({ offset: true }).transform(v => new Date(v)),
|
|
96
102
|
currency: z.nullable(z.string()),
|
|
103
|
+
discounted_from_amount: z.nullable(z.number().int()),
|
|
104
|
+
minimum_amount: z.nullable(z.number().int()),
|
|
105
|
+
maximum_amount: z.nullable(z.number().int()),
|
|
106
|
+
preset_amount: z.nullable(z.number().int()),
|
|
107
|
+
waitlist: z.boolean(),
|
|
108
|
+
benefits: z.array(z.string()).optional(),
|
|
109
|
+
purchase_url: z.string(),
|
|
97
110
|
product: z.string(),
|
|
98
|
-
x402_amount: z.string(),
|
|
99
111
|
}).transform((v) => {
|
|
100
112
|
return remap$(v, {
|
|
101
113
|
"amount_type": "amountType",
|
|
@@ -107,7 +119,11 @@ export const PriceVariant$inboundSchema: z.ZodType<
|
|
|
107
119
|
"quantity_available": "quantityAvailable",
|
|
108
120
|
"created_at": "createdAt",
|
|
109
121
|
"updated_at": "updatedAt",
|
|
110
|
-
"
|
|
122
|
+
"discounted_from_amount": "discountedFromAmount",
|
|
123
|
+
"minimum_amount": "minimumAmount",
|
|
124
|
+
"maximum_amount": "maximumAmount",
|
|
125
|
+
"preset_amount": "presetAmount",
|
|
126
|
+
"purchase_url": "purchaseUrl",
|
|
111
127
|
});
|
|
112
128
|
});
|
|
113
129
|
|
package/src/models/product.ts
CHANGED
|
@@ -8,8 +8,13 @@ import { safeParse } from "../lib/schemas.js";
|
|
|
8
8
|
import { ClosedEnum } from "../types/enums.js";
|
|
9
9
|
import { Result as SafeParseResult } from "../types/fp.js";
|
|
10
10
|
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
11
|
+
import {
|
|
12
|
+
MediaGalleryItem,
|
|
13
|
+
MediaGalleryItem$inboundSchema,
|
|
14
|
+
} from "./mediagalleryitem.js";
|
|
11
15
|
import { PriceVariant, PriceVariant$inboundSchema } from "./pricevariant.js";
|
|
12
16
|
import { Review, Review$inboundSchema } from "./review.js";
|
|
17
|
+
import { Seo, Seo$inboundSchema } from "./seo.js";
|
|
13
18
|
|
|
14
19
|
export const ProductStatus = {
|
|
15
20
|
Draft: "draft",
|
|
@@ -18,6 +23,11 @@ export const ProductStatus = {
|
|
|
18
23
|
} as const;
|
|
19
24
|
export type ProductStatus = ClosedEnum<typeof ProductStatus>;
|
|
20
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Prefix ID by default, full object when expanded
|
|
28
|
+
*/
|
|
29
|
+
export type SeoUnion = Seo | string;
|
|
30
|
+
|
|
21
31
|
export type Product = {
|
|
22
32
|
id: string;
|
|
23
33
|
object: string;
|
|
@@ -27,7 +37,19 @@ export type Product = {
|
|
|
27
37
|
description: string;
|
|
28
38
|
createdAt: Date;
|
|
29
39
|
updatedAt: Date;
|
|
40
|
+
bodyHtml: string;
|
|
41
|
+
buttonCta: string | null;
|
|
30
42
|
url: string;
|
|
43
|
+
availableFrom: Date | null;
|
|
44
|
+
availableUntil: Date | null;
|
|
45
|
+
publishedAt: Date | null;
|
|
46
|
+
reviewsCount: number;
|
|
47
|
+
averageRating: number | null;
|
|
48
|
+
/**
|
|
49
|
+
* Prefix ID by default, full object when expanded
|
|
50
|
+
*/
|
|
51
|
+
seo?: Seo | string | null | undefined;
|
|
52
|
+
mediaGallery: Array<MediaGalleryItem>;
|
|
31
53
|
priceVariants: Array<PriceVariant>;
|
|
32
54
|
reviews?: Array<Review> | undefined;
|
|
33
55
|
};
|
|
@@ -37,6 +59,23 @@ export const ProductStatus$inboundSchema: z.ZodNativeEnum<
|
|
|
37
59
|
typeof ProductStatus
|
|
38
60
|
> = z.nativeEnum(ProductStatus);
|
|
39
61
|
|
|
62
|
+
/** @internal */
|
|
63
|
+
export const SeoUnion$inboundSchema: z.ZodType<
|
|
64
|
+
SeoUnion,
|
|
65
|
+
z.ZodTypeDef,
|
|
66
|
+
unknown
|
|
67
|
+
> = z.union([Seo$inboundSchema, z.string()]);
|
|
68
|
+
|
|
69
|
+
export function seoUnionFromJSON(
|
|
70
|
+
jsonString: string,
|
|
71
|
+
): SafeParseResult<SeoUnion, SDKValidationError> {
|
|
72
|
+
return safeParse(
|
|
73
|
+
jsonString,
|
|
74
|
+
(x) => SeoUnion$inboundSchema.parse(JSON.parse(x)),
|
|
75
|
+
`Failed to parse 'SeoUnion' from JSON`,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
40
79
|
/** @internal */
|
|
41
80
|
export const Product$inboundSchema: z.ZodType<Product, z.ZodTypeDef, unknown> =
|
|
42
81
|
z.object({
|
|
@@ -52,13 +91,36 @@ export const Product$inboundSchema: z.ZodType<Product, z.ZodTypeDef, unknown> =
|
|
|
52
91
|
updated_at: z.string().datetime({ offset: true }).transform(v =>
|
|
53
92
|
new Date(v)
|
|
54
93
|
),
|
|
94
|
+
body_html: z.string(),
|
|
95
|
+
button_cta: z.nullable(z.string()),
|
|
55
96
|
url: z.string(),
|
|
97
|
+
available_from: z.nullable(
|
|
98
|
+
z.string().datetime({ offset: true }).transform(v => new Date(v)),
|
|
99
|
+
),
|
|
100
|
+
available_until: z.nullable(
|
|
101
|
+
z.string().datetime({ offset: true }).transform(v => new Date(v)),
|
|
102
|
+
),
|
|
103
|
+
published_at: z.nullable(
|
|
104
|
+
z.string().datetime({ offset: true }).transform(v => new Date(v)),
|
|
105
|
+
),
|
|
106
|
+
reviews_count: z.number().int(),
|
|
107
|
+
average_rating: z.nullable(z.number()),
|
|
108
|
+
seo: z.nullable(z.union([Seo$inboundSchema, z.string()])).optional(),
|
|
109
|
+
media_gallery: z.array(MediaGalleryItem$inboundSchema),
|
|
56
110
|
price_variants: z.array(PriceVariant$inboundSchema),
|
|
57
111
|
reviews: z.array(Review$inboundSchema).optional(),
|
|
58
112
|
}).transform((v) => {
|
|
59
113
|
return remap$(v, {
|
|
60
114
|
"created_at": "createdAt",
|
|
61
115
|
"updated_at": "updatedAt",
|
|
116
|
+
"body_html": "bodyHtml",
|
|
117
|
+
"button_cta": "buttonCta",
|
|
118
|
+
"available_from": "availableFrom",
|
|
119
|
+
"available_until": "availableUntil",
|
|
120
|
+
"published_at": "publishedAt",
|
|
121
|
+
"reviews_count": "reviewsCount",
|
|
122
|
+
"average_rating": "averageRating",
|
|
123
|
+
"media_gallery": "mediaGallery",
|
|
62
124
|
"price_variants": "priceVariants",
|
|
63
125
|
});
|
|
64
126
|
});
|
package/src/models/review.ts
CHANGED
|
@@ -15,6 +15,7 @@ export type Review = {
|
|
|
15
15
|
customerName: string | null;
|
|
16
16
|
content: string | null;
|
|
17
17
|
createdAt: Date;
|
|
18
|
+
customerImageUrl: string | null;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
/** @internal */
|
|
@@ -28,10 +29,12 @@ export const Review$inboundSchema: z.ZodType<Review, z.ZodTypeDef, unknown> = z
|
|
|
28
29
|
created_at: z.string().datetime({ offset: true }).transform(v =>
|
|
29
30
|
new Date(v)
|
|
30
31
|
),
|
|
32
|
+
customer_image_url: z.nullable(z.string()),
|
|
31
33
|
}).transform((v) => {
|
|
32
34
|
return remap$(v, {
|
|
33
35
|
"customer_name": "customerName",
|
|
34
36
|
"created_at": "createdAt",
|
|
37
|
+
"customer_image_url": "customerImageUrl",
|
|
35
38
|
});
|
|
36
39
|
});
|
|
37
40
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { safeParse } from "../lib/schemas.js";
|
|
7
|
+
import { Result as SafeParseResult } from "../types/fp.js";
|
|
8
|
+
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
9
|
+
|
|
10
|
+
export type Seo = {
|
|
11
|
+
title: string | null;
|
|
12
|
+
description: string | null;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** @internal */
|
|
16
|
+
export const Seo$inboundSchema: z.ZodType<Seo, z.ZodTypeDef, unknown> = z
|
|
17
|
+
.object({
|
|
18
|
+
title: z.nullable(z.string()),
|
|
19
|
+
description: z.nullable(z.string()),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export function seoFromJSON(
|
|
23
|
+
jsonString: string,
|
|
24
|
+
): SafeParseResult<Seo, SDKValidationError> {
|
|
25
|
+
return safeParse(
|
|
26
|
+
jsonString,
|
|
27
|
+
(x) => Seo$inboundSchema.parse(JSON.parse(x)),
|
|
28
|
+
`Failed to parse 'Seo' from JSON`,
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { safeParse } from "../lib/schemas.js";
|
|
7
|
+
import { ClosedEnum } from "../types/enums.js";
|
|
8
|
+
import { Result as SafeParseResult } from "../types/fp.js";
|
|
9
|
+
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
10
|
+
|
|
11
|
+
export const Platform = {
|
|
12
|
+
Facebook: "facebook",
|
|
13
|
+
Twitter: "twitter",
|
|
14
|
+
Instagram: "instagram",
|
|
15
|
+
Linkedin: "linkedin",
|
|
16
|
+
Youtube: "youtube",
|
|
17
|
+
Tiktok: "tiktok",
|
|
18
|
+
Pinterest: "pinterest",
|
|
19
|
+
Discord: "discord",
|
|
20
|
+
Twitch: "twitch",
|
|
21
|
+
Telegram: "telegram",
|
|
22
|
+
Email: "email",
|
|
23
|
+
Url: "url",
|
|
24
|
+
} as const;
|
|
25
|
+
export type Platform = ClosedEnum<typeof Platform>;
|
|
26
|
+
|
|
27
|
+
export type SocialLink = {
|
|
28
|
+
platform: Platform;
|
|
29
|
+
url: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** @internal */
|
|
33
|
+
export const Platform$inboundSchema: z.ZodNativeEnum<typeof Platform> = z
|
|
34
|
+
.nativeEnum(Platform);
|
|
35
|
+
|
|
36
|
+
/** @internal */
|
|
37
|
+
export const SocialLink$inboundSchema: z.ZodType<
|
|
38
|
+
SocialLink,
|
|
39
|
+
z.ZodTypeDef,
|
|
40
|
+
unknown
|
|
41
|
+
> = z.object({
|
|
42
|
+
platform: Platform$inboundSchema,
|
|
43
|
+
url: z.string(),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export function socialLinkFromJSON(
|
|
47
|
+
jsonString: string,
|
|
48
|
+
): SafeParseResult<SocialLink, SDKValidationError> {
|
|
49
|
+
return safeParse(
|
|
50
|
+
jsonString,
|
|
51
|
+
(x) => SocialLink$inboundSchema.parse(JSON.parse(x)),
|
|
52
|
+
`Failed to parse 'SocialLink' from JSON`,
|
|
53
|
+
);
|
|
54
|
+
}
|
package/test-sdk.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Simple Bun test script to verify @crevio/sdk against the local dev server.
|
|
3
|
-
*
|
|
4
|
-
* Usage:
|
|
5
|
-
* API_KEY=<your_api_key> bun run test-sdk.ts
|
|
6
|
-
*
|
|
7
|
-
* The local dev server runs at https://api.crevio.localhost/v1 (serverIdx: 1)
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { Crevio } from "./src/index.js";
|
|
11
|
-
|
|
12
|
-
const apiKey = process.env.API_KEY;
|
|
13
|
-
if (!apiKey) {
|
|
14
|
-
console.error("ERROR: Set API_KEY env var before running this script.");
|
|
15
|
-
process.exit(1);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const sdk = new Crevio({
|
|
19
|
-
apiKeyAuth: apiKey,
|
|
20
|
-
serverIdx: 1, // https://api.crevio.localhost/v1
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
type Result = { ok: boolean; data?: unknown; error?: string };
|
|
24
|
-
|
|
25
|
-
async function test(label: string, fn: () => Promise<unknown>): Promise<void> {
|
|
26
|
-
process.stdout.write(` ${label} ... `);
|
|
27
|
-
try {
|
|
28
|
-
const data = await fn();
|
|
29
|
-
console.log("✓");
|
|
30
|
-
if (process.env.VERBOSE) console.log(JSON.stringify(data, null, 2));
|
|
31
|
-
} catch (err: unknown) {
|
|
32
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
33
|
-
console.log(`✗ ${msg}`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
console.log("\n=== Crevio SDK smoke tests ===\n");
|
|
38
|
-
|
|
39
|
-
// ── Store ──────────────────────────────────────────────────────────────────
|
|
40
|
-
console.log("Store");
|
|
41
|
-
await test("GET /account", () => sdk.account.get());
|
|
42
|
-
|
|
43
|
-
// ── Catalog ───────────────────────────────────────────────────────────────
|
|
44
|
-
console.log("\nCatalog");
|
|
45
|
-
await test("GET /products", () => sdk.products.list());
|
|
46
|
-
await test("GET /price_variants", () => sdk.priceVariants.list());
|
|
47
|
-
await test("GET /reviews", () => sdk.reviews.list());
|
|
48
|
-
await test("GET /experiences", () => sdk.experiences.list());
|
|
49
|
-
await test("GET /blog_posts", () => sdk.blogPosts.list());
|
|
50
|
-
|
|
51
|
-
// ── CRM ───────────────────────────────────────────────────────────────────
|
|
52
|
-
console.log("\nCRM");
|
|
53
|
-
await test("GET /orders", () => sdk.orders.list());
|
|
54
|
-
await test("GET /customers", () => sdk.customers.list());
|
|
55
|
-
await test("GET /discounts", () => sdk.discounts.list());
|
|
56
|
-
await test("GET /checkout_links", () => sdk.checkoutLinks.list());
|
|
57
|
-
|
|
58
|
-
// ── Cart/Checkout ─────────────────────────────────────────────────────────
|
|
59
|
-
// These require a product to exist; we skip deep tests but verify the endpoint
|
|
60
|
-
// is reachable (expect a 422/400, NOT a 404/401 routing error).
|
|
61
|
-
console.log("\nCart & Checkout (expects 4xx, not 404)");
|
|
62
|
-
await test("POST /carts", async () => {
|
|
63
|
-
try {
|
|
64
|
-
await sdk.carts.create({ items: [] });
|
|
65
|
-
} catch (err: unknown) {
|
|
66
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
67
|
-
// A 422/400 means the route exists — that's all we're checking here
|
|
68
|
-
if (/422|400|unprocessable|bad request/i.test(msg)) return "route exists (4xx)";
|
|
69
|
-
throw err;
|
|
70
|
-
}
|
|
71
|
-
return "created";
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
console.log("\nDone.\n");
|