@nodaro/sdk 1.11.0 → 1.13.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/index.cjs +51 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +192 -1
- package/dist/index.d.ts +192 -1
- package/dist/index.js +50 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1933,6 +1933,7 @@ var LibraryResource = class {
|
|
|
1933
1933
|
if (params.limit !== void 0) qs.set("limit", String(params.limit));
|
|
1934
1934
|
if (params.cursor) qs.set("cursor", params.cursor);
|
|
1935
1935
|
if (params.owned !== void 0) qs.set("owned", String(params.owned));
|
|
1936
|
+
if (params.source) qs.set("source", params.source);
|
|
1936
1937
|
const query = qs.toString();
|
|
1937
1938
|
return this.client.request("GET", `/v1/library${query ? `?${query}` : ""}`);
|
|
1938
1939
|
}
|
|
@@ -2117,11 +2118,52 @@ var CommunityResource = class {
|
|
|
2117
2118
|
}
|
|
2118
2119
|
};
|
|
2119
2120
|
|
|
2121
|
+
// src/resources/templates.ts
|
|
2122
|
+
var TemplatesResource = class {
|
|
2123
|
+
constructor(client) {
|
|
2124
|
+
this.client = client;
|
|
2125
|
+
}
|
|
2126
|
+
client;
|
|
2127
|
+
/** Browse the public template marketplace (cursor-paginated, no auth required). */
|
|
2128
|
+
browse(params = {}) {
|
|
2129
|
+
return this.client.request("GET", "/v1/templates/browse", { query: { ...params } });
|
|
2130
|
+
}
|
|
2131
|
+
/** Fetch one public template by slug, including its full workflow snapshot. */
|
|
2132
|
+
get(slug) {
|
|
2133
|
+
return this.client.request("GET", `/v1/templates/${encodeURIComponent(slug)}`);
|
|
2134
|
+
}
|
|
2135
|
+
/** Clone a template into one of the caller's projects. Free — no credits charged. */
|
|
2136
|
+
clone(slug, params) {
|
|
2137
|
+
return this.client.request("POST", `/v1/templates/${encodeURIComponent(slug)}/clone`, {
|
|
2138
|
+
body: params
|
|
2139
|
+
});
|
|
2140
|
+
}
|
|
2141
|
+
};
|
|
2142
|
+
|
|
2143
|
+
// src/resources/tutorials.ts
|
|
2144
|
+
var TutorialsResource = class {
|
|
2145
|
+
constructor(client) {
|
|
2146
|
+
this.client = client;
|
|
2147
|
+
}
|
|
2148
|
+
client;
|
|
2149
|
+
/** All enabled tutorial categories with their videos and flow tutorials. Public. */
|
|
2150
|
+
list() {
|
|
2151
|
+
return this.client.request("GET", "/v1/tutorials");
|
|
2152
|
+
}
|
|
2153
|
+
};
|
|
2154
|
+
|
|
2120
2155
|
// src/client.ts
|
|
2156
|
+
var SDK_VERSION = "1.13.0" ;
|
|
2157
|
+
var CLIENT_HEADER = "X-Nodaro-Client";
|
|
2158
|
+
var isBrowser = () => typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
2121
2159
|
var NodaroClient = class {
|
|
2122
2160
|
baseUrl;
|
|
2123
2161
|
auth;
|
|
2124
2162
|
timeoutMs;
|
|
2163
|
+
/** Value sent as `X-Nodaro-Client`; recorded by the backend as job provenance. */
|
|
2164
|
+
clientLabel;
|
|
2165
|
+
/** Whether to actually send it — see the note on {@link CLIENT_HEADER}. */
|
|
2166
|
+
sendClientHeader;
|
|
2125
2167
|
fetchOverride;
|
|
2126
2168
|
/**
|
|
2127
2169
|
* Resolved lazily so consumers can swap `globalThis.fetch` after the
|
|
@@ -2157,11 +2199,15 @@ var NodaroClient = class {
|
|
|
2157
2199
|
presets;
|
|
2158
2200
|
pickerCatalogs;
|
|
2159
2201
|
community;
|
|
2202
|
+
templates;
|
|
2203
|
+
tutorials;
|
|
2160
2204
|
constructor(opts) {
|
|
2161
2205
|
this.baseUrl = opts.baseUrl.replace(/\/$/, "");
|
|
2162
2206
|
this.auth = opts.auth;
|
|
2163
2207
|
this.fetchOverride = opts.fetch;
|
|
2164
2208
|
this.timeoutMs = opts.timeoutMs ?? 6e4;
|
|
2209
|
+
this.clientLabel = opts.clientLabel ?? `sdk/${SDK_VERSION}`;
|
|
2210
|
+
this.sendClientHeader = opts.clientLabel !== void 0 || !isBrowser();
|
|
2165
2211
|
this.workflows = new WorkflowsResource(this);
|
|
2166
2212
|
this.projects = new ProjectsResource(this);
|
|
2167
2213
|
this.jobs = new JobsResource(this);
|
|
@@ -2187,6 +2233,8 @@ var NodaroClient = class {
|
|
|
2187
2233
|
this.presets = new PresetsResource(this);
|
|
2188
2234
|
this.pickerCatalogs = new PickerCatalogsResource(this);
|
|
2189
2235
|
this.community = new CommunityResource(this);
|
|
2236
|
+
this.templates = new TemplatesResource(this);
|
|
2237
|
+
this.tutorials = new TutorialsResource(this);
|
|
2190
2238
|
}
|
|
2191
2239
|
async request(method, path, options = {}) {
|
|
2192
2240
|
const url = this.buildUrl(path, options.query);
|
|
@@ -2194,6 +2242,7 @@ var NodaroClient = class {
|
|
|
2194
2242
|
const isFormData = typeof FormData !== "undefined" && options.body instanceof FormData;
|
|
2195
2243
|
const headers = {
|
|
2196
2244
|
...isFormData ? {} : { "Content-Type": "application/json" },
|
|
2245
|
+
...this.sendClientHeader ? { [CLIENT_HEADER]: this.clientLabel } : {},
|
|
2197
2246
|
...options.headers ?? {}
|
|
2198
2247
|
};
|
|
2199
2248
|
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
@@ -2380,6 +2429,8 @@ exports.RateLimitedError = RateLimitedError;
|
|
|
2380
2429
|
exports.ReduceResource = ReduceResource;
|
|
2381
2430
|
exports.StaticTokenAuth = StaticTokenAuth;
|
|
2382
2431
|
exports.StorageExceededError = StorageExceededError;
|
|
2432
|
+
exports.TemplatesResource = TemplatesResource;
|
|
2433
|
+
exports.TutorialsResource = TutorialsResource;
|
|
2383
2434
|
exports.UnauthorizedError = UnauthorizedError;
|
|
2384
2435
|
exports.UploadsResource = UploadsResource;
|
|
2385
2436
|
exports.VideoProResource = VideoProResource;
|