@gethydra/sdk 0.1.47 → 0.1.48
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.d.ts +716 -184
- package/dist/index.js +69 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1807,6 +1807,70 @@ var GiftCardsResource = class {
|
|
|
1807
1807
|
}
|
|
1808
1808
|
};
|
|
1809
1809
|
|
|
1810
|
+
// src/resources/forms.ts
|
|
1811
|
+
var FormsResource = class {
|
|
1812
|
+
constructor(client) {
|
|
1813
|
+
this.client = client;
|
|
1814
|
+
}
|
|
1815
|
+
client;
|
|
1816
|
+
// ── Form definitions ──
|
|
1817
|
+
/** List all form definitions (including archived). Secret key required. */
|
|
1818
|
+
async list() {
|
|
1819
|
+
return this.client.request("GET", "/v1/store/forms");
|
|
1820
|
+
}
|
|
1821
|
+
/** Get a single form definition by slug. Secret key required. */
|
|
1822
|
+
async get(slug) {
|
|
1823
|
+
return this.client.request("GET", `/v1/store/forms/${slug}`);
|
|
1824
|
+
}
|
|
1825
|
+
/** Create a new form definition. Secret key required. */
|
|
1826
|
+
async create(body, options) {
|
|
1827
|
+
return this.client.request("POST", "/v1/store/forms", { body, ...options });
|
|
1828
|
+
}
|
|
1829
|
+
/** Update a form definition (title, slug, settings, archived). Secret key required. */
|
|
1830
|
+
async update(slug, body) {
|
|
1831
|
+
return this.client.request("PATCH", `/v1/store/forms/${slug}`, { body });
|
|
1832
|
+
}
|
|
1833
|
+
/** Get a form's active fields and settings for public rendering. Publishable key accepted. */
|
|
1834
|
+
async getPublic(slug) {
|
|
1835
|
+
return this.client.request("GET", `/v1/store/forms/${slug}/public`);
|
|
1836
|
+
}
|
|
1837
|
+
// ── Fields within a form ──
|
|
1838
|
+
/** Add a field to a form. Secret key required. */
|
|
1839
|
+
async createField(formSlug, body, options) {
|
|
1840
|
+
return this.client.request("POST", `/v1/store/forms/${formSlug}/fields`, { body, ...options });
|
|
1841
|
+
}
|
|
1842
|
+
/** Update a field within a form. Secret key required. */
|
|
1843
|
+
async updateField(formSlug, fieldSlug, body) {
|
|
1844
|
+
return this.client.request("PATCH", `/v1/store/forms/${formSlug}/fields/${fieldSlug}`, { body });
|
|
1845
|
+
}
|
|
1846
|
+
};
|
|
1847
|
+
|
|
1848
|
+
// src/resources/form-submissions.ts
|
|
1849
|
+
var FormSubmissionsResource = class {
|
|
1850
|
+
constructor(client) {
|
|
1851
|
+
this.client = client;
|
|
1852
|
+
}
|
|
1853
|
+
client;
|
|
1854
|
+
/** Submit form data. Publishable key accepted. */
|
|
1855
|
+
async create(body, options) {
|
|
1856
|
+
return this.client.request("POST", "/v1/form-submissions", { body, ...options });
|
|
1857
|
+
}
|
|
1858
|
+
/** List form submissions with optional form slug filter. Secret key required. */
|
|
1859
|
+
async list(params) {
|
|
1860
|
+
return this.client.request("GET", "/v1/form-submissions", { params });
|
|
1861
|
+
}
|
|
1862
|
+
iterate(params, options) {
|
|
1863
|
+
return paginate((cursor) => this.list({ ...params, cursor }), options);
|
|
1864
|
+
}
|
|
1865
|
+
async toArray(params, options) {
|
|
1866
|
+
return toArray(this.iterate(params, options), options);
|
|
1867
|
+
}
|
|
1868
|
+
/** Get a single form submission by ID. Secret key required. */
|
|
1869
|
+
async get(id) {
|
|
1870
|
+
return this.client.request("GET", `/v1/form-submissions/${id}`);
|
|
1871
|
+
}
|
|
1872
|
+
};
|
|
1873
|
+
|
|
1810
1874
|
// src/resources/auth.ts
|
|
1811
1875
|
var AuthResource = class {
|
|
1812
1876
|
constructor(client) {
|
|
@@ -2050,6 +2114,9 @@ var Hydra = class {
|
|
|
2050
2114
|
// P12: Customer Auth
|
|
2051
2115
|
auth = new AuthResource(this);
|
|
2052
2116
|
me = new MeResource(this);
|
|
2117
|
+
// P13: Forms
|
|
2118
|
+
forms = new FormsResource(this);
|
|
2119
|
+
formSubmissions = new FormSubmissionsResource(this);
|
|
2053
2120
|
constructor(config) {
|
|
2054
2121
|
for (const key of Object.keys(config)) {
|
|
2055
2122
|
if (!VALID_CONFIG_KEYS.has(key)) {
|
|
@@ -2282,6 +2349,8 @@ export {
|
|
|
2282
2349
|
DiscountsResource,
|
|
2283
2350
|
DraftOrdersResource,
|
|
2284
2351
|
ExchangeRatesResource,
|
|
2352
|
+
FormSubmissionsResource,
|
|
2353
|
+
FormsResource,
|
|
2285
2354
|
FulfillmentOrdersResource,
|
|
2286
2355
|
FulfillmentsResource,
|
|
2287
2356
|
GiftCardsResource,
|