@knapsack/app-client-api 4.69.8--canary.4746.1acd21a.0 → 4.69.8--canary.4532.626b8d9.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -1,10 +1,20 @@
1
- import { KsAppClientData, PluginsApi, KsRenderResults } from '@knapsack/types';
1
+ import { KsAppClientData, PluginsApi } from '@knapsack/types';
2
2
  import type { GenericResponse, KsAppClientDataAndMeta, KsAppClientDataNoMeta, KsFileSaverParams } from '@knapsack/types';
3
3
  import * as getTemplateSuggestions from './get-template-suggestions';
4
4
  export { getTemplateSuggestions };
5
5
  export interface KnapsackDataStoreSaveBody {
6
6
  state: KsAppClientData;
7
7
  }
8
+ export interface KnapsackTemplateRendererResults {
9
+ ok: boolean;
10
+ html: string;
11
+ usage?: string;
12
+ templateLanguage?: string;
13
+ message?: string;
14
+ }
15
+ export interface KsRenderResults extends KnapsackTemplateRendererResults {
16
+ wrappedHtml: string;
17
+ }
8
18
  export type PatternRenderData = {
9
19
  patternId: string;
10
20
  templateId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,sBAAsB,MAAM,4BAA4B,CAAC;AAErE,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAElC,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,eAAe,CAAC;CACxB;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,C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E;AAED,wBAAsB,YAAY,CAAC,EACjC,YAAY,GACb,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,eAAe,CAAC,sBAAsB,CAAC,CAAC,CAgBnD;AAGD,wBAAsB,gBAAgB,CAAC,EACrC,YAAY,GACb,EAAE;IACD,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAQlC;AAED,qDAAqD;AACrD,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,eAAe,GACrB,qBAAqB,CAGvB;AAED,wBAAsB,sBAAsB,CAAC,EAC3C,OAAO,EACP,KAAK,GACN,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,qBAAqB,CAAC;CAC9B,GAAG,OAAO,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC,CAiB9C;AAED,wBAAsB,qBAAqB,CAAC,EAC1C,OAAO,EACP,KAAK,GACN,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,qBAAqB,CAAC;CAC9B,GAAG,OAAO,CAAC,IAAI,CAAC,CAahB;AAED,wBAAsB,gBAAgB,CAAC,EACrC,QAAQ,EACR,YAAY,GACb,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAUzC;AAED,wBAAsB,cAAc,CAAC,EACnC,OAAO,EACP,YAAY,GACb,EAAE;IACD,OAAO,EAAE,iBAAiB,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,eAAe,CAAC,CAM3B"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/get-template-suggestions.ts"],"sourcesContent":["import { KsAppClientData, PluginsApi, KsRenderResults } from '@knapsack/types';\nimport type {\n GenericResponse,\n KsAppClientDataAndMeta,\n KsAppClientDataNoMeta,\n KsFileSaverParams,\n} from '@knapsack/types';\nimport { fetcher } from '@knapsack/utils';\nimport * as getTemplateSuggestions from './get-template-suggestions';\n\nexport { getTemplateSuggestions };\n\nexport interface KnapsackDataStoreSaveBody {\n state: KsAppClientData;\n}\n\nexport type PatternRenderData = {\n patternId: string;\n templateId: string;\n /**\n * Data id from `saveData()`\n * Cannot use with `demoId`\n */\n dataId?: string;\n /**\n * Cannot use with `dataId`\n */\n demoId?: string;\n assetSetId?: string;\n wrapHtml?: boolean;\n isInIframe?: boolean;\n cacheBuster?: string;\n};\n\nexport const ENDPOINTS = {\n health: '/api/v1/',\n dataStore: '/api/v1/data-store',\n dataStorePrep: '/api/v1/data-store-prep',\n files: '/api/v1/files',\n data: '/api/v1/data',\n render: '/api/v1/render',\n upload: '/api/v1/upload',\n plugins: '/api/v1/plugins',\n getTemplateSuggestions: getTemplateSuggestions.path,\n};\n\nexport async function checkAppClientUrl(url: string): Promise<GenericResponse> {\n try {\n const theUrl = new URL(ENDPOINTS.health, url); // will throw if url not formatted correctly\n const res = await fetcher<GenericResponse>({\n url: theUrl.toString(),\n });\n return res;\n } catch (e) {\n return {\n ok: false,\n message: e.message,\n };\n }\n}\n\nexport async function getDataStore({\n appClientUrl,\n}: {\n appClientUrl: string;\n}): Promise<GenericResponse<KsAppClientDataAndMeta>> {\n try {\n const data = await fetcher<KsAppClientDataAndMeta>({\n url: new URL(ENDPOINTS.dataStore, appClientUrl).toString(),\n });\n\n return {\n ok: true,\n data,\n };\n } catch (err) {\n return {\n ok: false,\n message: err.message,\n };\n }\n}\n\n// just need a function that can throw an error\nexport async function getAppClientData({\n appClientUrl,\n}: {\n appClientUrl: string;\n}): Promise<KsAppClientDataAndMeta> {\n const serverDataRes = await getDataStore({ appClientUrl });\n // console.log(`getDataStore() response`, serverDataRes);\n if (!serverDataRes.ok) {\n const message = `Could not load data from custom url \"${appClientUrl}\" ${serverDataRes.message}`;\n throw new Error(message);\n }\n return serverDataRes.data;\n}\n\n/** Sole job is to strip `metaState` if it's there */\nexport function prepAppClientData(\n state: KsAppClientData,\n): KsAppClientDataNoMeta {\n const { metaState, ...appClientDataNoMeta } = state;\n return appClientDataNoMeta;\n}\n\nexport async function prepareDataForFileSave({\n urlBase,\n state,\n}: {\n urlBase: string;\n state: KsAppClientDataNoMeta;\n}): Promise<GenericResponse<KsFileSaverParams>> {\n try {\n const body: KnapsackDataStoreSaveBody = {\n state: prepAppClientData(state),\n };\n const data = await fetcher<GenericResponse<KsFileSaverParams>>({\n url: new URL(ENDPOINTS.dataStorePrep, urlBase).toString(),\n body,\n });\n\n return data;\n } catch (err) {\n return {\n ok: false,\n message: err.message,\n };\n }\n}\n\nexport async function submitDataForFileSave({\n urlBase,\n state,\n}: {\n urlBase: string;\n state: KsAppClientDataNoMeta;\n}): Promise<void> {\n const appClientData = prepAppClientData(state);\n const body: KnapsackDataStoreSaveBody = {\n state: appClientData,\n };\n const data = await fetcher<GenericResponse>({\n url: new URL(ENDPOINTS.dataStore, urlBase).toString(),\n body,\n });\n\n if (!data.ok) {\n throw new Error(`Could not save data to localhost files: ${data.message}`);\n }\n}\n\nexport async function getPluginContent({\n pluginId,\n appClientUrl,\n}: {\n pluginId: string;\n appClientUrl: string;\n}): Promise<PluginsApi.GetContentResponse> {\n const body: PluginsApi.GetContentRequest = {\n pluginId,\n type: PluginsApi.ACTIONS.getContent,\n };\n const data = await fetcher<PluginsApi.GetContentResponse>({\n url: new URL(ENDPOINTS.plugins, appClientUrl).toString(),\n body,\n });\n return data;\n}\n\nexport async function renderTemplate({\n options,\n appClientUrl,\n}: {\n options: PatternRenderData;\n appClientUrl: string;\n}): Promise<KsRenderResults> {\n const data = await fetcher<KsRenderResults>({\n url: new URL(ENDPOINTS.render, appClientUrl).toString(),\n body: options,\n });\n return data;\n}\n","import type { TemplateSuggestionsGetFn } from '@knapsack/types';\nimport { fetcher } from '@knapsack/utils';\n\nexport const path = '/api/v1/template-suggestions';\nexport const method = 'GET';\nexport type ReqParams = Parameters<TemplateSuggestionsGetFn>[0];\nexport type ResBody =\n | {\n type: 'success';\n data: Awaited<ReturnType<TemplateSuggestionsGetFn>>;\n }\n | {\n type: 'error.invalidParams';\n message: string;\n }\n | {\n type: 'error.pathNotFound';\n message: string;\n }\n | {\n type: 'error.couldNotParse';\n message: string;\n };\n\nexport async function getTemplateSuggestions({\n appClientUrl,\n query,\n}: {\n appClientUrl: string;\n query: ReqParams;\n}): Promise<ResBody> {\n return fetcher<ResBody>({\n url: new URL(path, appClientUrl).toString(),\n query,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA6D;AAO7D,IAAAA,gBAAwB;;;ACPxB;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAwB;AAEjB,IAAM,OAAO;AACb,IAAM,SAAS;AAoBtB,eAAsB,uBAAuB;AAAA,EAC3C;AAAA,EACA;AACF,GAGqB;AACnB,aAAO,sBAAiB;AAAA,IACtB,KAAK,IAAI,IAAI,MAAM,YAAY,EAAE,SAAS;AAAA,IAC1C;AAAA,EACF,CAAC;AACH;AAXsB;;;ADUf,IAAM,YAAY;AAAA,EACvB,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,eAAe;AAAA,EACf,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,wBAA+C;AACjD;AAEA,eAAsB,kBAAkB,KAAuC;AAC7E,MAAI;AACF,UAAM,SAAS,IAAI,IAAI,UAAU,QAAQ,GAAG;AAC5C,UAAM,MAAM,UAAM,uBAAyB;AAAA,MACzC,KAAK,OAAO,SAAS;AAAA,IACvB,CAAC;AACD,WAAO;AAAA,EACT,SAAS,GAAG;AACV,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS,EAAE;AAAA,IACb;AAAA,EACF;A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yB;AAAA,IAC1C,KAAK,IAAI,IAAI,UAAU,WAAW,OAAO,EAAE,SAAS;AAAA,IACpD;AAAA,EACF,CAAC;AAED,MAAI,CAAC,KAAK,IAAI;AACZ,UAAM,IAAI,MAAM,2CAA2C,KAAK,OAAO,EAAE;AAAA,EAC3E;AACF;AAnBsB;AAqBtB,eAAsB,iBAAiB;AAAA,EACrC;AAAA,EACA;AACF,GAG2C;AACzC,QAAM,OAAqC;AAAA,IACzC;AAAA,IACA,MAAM,wBAAW,QAAQ;AAAA,EAC3B;AACA,QAAM,OAAO,UAAM,uBAAuC;AAAA,IACxD,KAAK,IAAI,IAAI,UAAU,SAAS,YAAY,EAAE,SAAS;AAAA,IACvD;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAhBsB;AAkBtB,eAAsB,eAAe;AAAA,EACnC;AAAA,EACA;AACF,GAG6B;AAC3B,QAAM,OAAO,UAAM,uBAAyB;AAAA,IAC1C,KAAK,IAAI,IAAI,UAAU,QAAQ,YAAY,EAAE,SAAS;AAAA,IACtD,MAAM;AAAA,EACR,CAAC;AACD,SAAO;AACT;AAZsB;","names":["import_utils"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/get-template-suggestions.ts"],"sourcesContent":["import { KsAppClientData, PluginsApi } from '@knapsack/types';\nimport type {\n GenericResponse,\n KsAppClientDataAndMeta,\n KsAppClientDataNoMeta,\n KsFileSaverParams,\n} from '@knapsack/types';\nimport { fetcher } from '@knapsack/utils';\nimport * as getTemplateSuggestions from './get-template-suggestions';\n\nexport { getTemplateSuggestions };\n\nexport interface KnapsackDataStoreSaveBody {\n state: KsAppClientData;\n}\n\nexport interface KnapsackTemplateRendererResults {\n ok: boolean;\n html: string;\n usage?: string;\n templateLanguage?: string;\n message?: string;\n}\n\nexport interface KsRenderResults extends KnapsackTemplateRendererResults {\n wrappedHtml: string;\n}\n\nexport type PatternRenderData = {\n patternId: string;\n templateId: string;\n /**\n * Data id from `saveData()`\n * Cannot use with `demoId`\n */\n dataId?: string;\n /**\n * Cannot use with `dataId`\n */\n demoId?: string;\n assetSetId?: string;\n wrapHtml?: boolean;\n isInIframe?: boolean;\n cacheBuster?: string;\n};\n\nexport const ENDPOINTS = {\n health: '/api/v1/',\n dataStore: '/api/v1/data-store',\n dataStorePrep: '/api/v1/data-store-prep',\n files: '/api/v1/files',\n data: '/api/v1/data',\n render: '/api/v1/render',\n upload: '/api/v1/upload',\n plugins: '/api/v1/plugins',\n getTemplateSuggestions: getTemplateSuggestions.path,\n};\n\nexport async function checkAppClientUrl(url: string): Promise<GenericResponse> {\n try {\n const theUrl = new URL(ENDPOINTS.health, url); // will throw if url not formatted correctly\n const res = await fetcher<GenericResponse>({\n url: theUrl.toString(),\n });\n return res;\n } catch (e) {\n return {\n ok: false,\n message: e.message,\n };\n }\n}\n\nexport async function getDataStore({\n appClientUrl,\n}: {\n appClientUrl: string;\n}): Promise<GenericResponse<KsAppClientDataAndMeta>> {\n try {\n const data = await fetcher<KsAppClientDataAndMeta>({\n url: new URL(ENDPOINTS.dataStore, appClientUrl).toString(),\n });\n\n return {\n ok: true,\n data,\n };\n } catch (err) {\n return {\n ok: false,\n message: err.message,\n };\n }\n}\n\n// just need a function that can throw an error\nexport async function getAppClientData({\n appClientUrl,\n}: {\n appClientUrl: string;\n}): Promise<KsAppClientDataAndMeta> {\n const serverDataRes = await getDataStore({ appClientUrl });\n // console.log(`getDataStore() response`, serverDataRes);\n if (!serverDataRes.ok) {\n const message = `Could not load data from custom url \"${appClientUrl}\" ${serverDataRes.message}`;\n throw new Error(message);\n }\n return serverDataRes.data;\n}\n\n/** Sole job is to strip `metaState` if it's there */\nexport function prepAppClientData(\n state: KsAppClientData,\n): KsAppClientDataNoMeta {\n const { metaState, ...appClientDataNoMeta } = state;\n return appClientDataNoMeta;\n}\n\nexport async function prepareDataForFileSave({\n urlBase,\n state,\n}: {\n urlBase: string;\n state: KsAppClientDataNoMeta;\n}): Promise<GenericResponse<KsFileSaverParams>> {\n try {\n const body: KnapsackDataStoreSaveBody = {\n state: prepAppClientData(state),\n };\n const data = await fetcher<GenericResponse<KsFileSaverParams>>({\n url: new URL(ENDPOINTS.dataStorePrep, urlBase).toString(),\n body,\n });\n\n return data;\n } catch (err) {\n return {\n ok: false,\n message: err.message,\n };\n }\n}\n\nexport async function submitDataForFileSave({\n urlBase,\n state,\n}: {\n urlBase: string;\n state: KsAppClientDataNoMeta;\n}): Promise<void> {\n const appClientData = prepAppClientData(state);\n const body: KnapsackDataStoreSaveBody = {\n state: appClientData,\n };\n const data = await fetcher<GenericResponse>({\n url: new URL(ENDPOINTS.dataStore, urlBase).toString(),\n body,\n });\n\n if (!data.ok) {\n throw new Error(`Could not save data to localhost files: ${data.message}`);\n }\n}\n\nexport async function getPluginContent({\n pluginId,\n appClientUrl,\n}: {\n pluginId: string;\n appClientUrl: string;\n}): Promise<PluginsApi.GetContentResponse> {\n const body: PluginsApi.GetContentRequest = {\n pluginId,\n type: PluginsApi.ACTIONS.getContent,\n };\n const data = await fetcher<PluginsApi.GetContentResponse>({\n url: new URL(ENDPOINTS.plugins, appClientUrl).toString(),\n body,\n });\n return data;\n}\n\nexport async function renderTemplate({\n options,\n appClientUrl,\n}: {\n options: PatternRenderData;\n appClientUrl: string;\n}): Promise<KsRenderResults> {\n const data = await fetcher<KsRenderResults>({\n url: new URL(ENDPOINTS.render, appClientUrl).toString(),\n body: options,\n });\n return data;\n}\n","import type { TemplateSuggestionsGetFn } from '@knapsack/types';\nimport { fetcher } from '@knapsack/utils';\n\nexport const path = '/api/v1/template-suggestions';\nexport const method = 'GET';\nexport type ReqParams = Parameters<TemplateSuggestionsGetFn>[0];\nexport type ResBody =\n | {\n type: 'success';\n data: Awaited<ReturnType<TemplateSuggestionsGetFn>>;\n }\n | {\n type: 'error.invalidParams';\n message: string;\n }\n | {\n type: 'error.pathNotFound';\n message: string;\n }\n | {\n type: 'error.couldNotParse';\n message: string;\n };\n\nexport async function getTemplateSuggestions({\n appClientUrl,\n query,\n}: {\n appClientUrl: string;\n query: ReqParams;\n}): Promise<ResBody> {\n return fetcher<ResBody>({\n url: new URL(path, appClientUrl).toString(),\n query,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA4C;AAO5C,IAAAA,gBAAwB;;;ACPxB;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAwB;AAEjB,IAAM,OAAO;AACb,IAAM,SAAS;AAoBtB,eAAsB,uBAAuB;AAAA,EAC3C;AAAA,EACA;AACF,GAGqB;AACnB,aAAO,sBAAiB;AAAA,IACtB,KAAK,IAAI,IAAI,MAAM,YAAY,EAAE,SAAS;AAAA,IAC1C;AAAA,EACF,CAAC;AACH;AAXsB;;;ADsBf,IAAM,YAAY;AAAA,EACvB,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,eAAe;AAAA,EACf,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,wBAA+C;AACjD;AAEA,eAAsB,kBAAkB,KAAuC;AAC7E,MAAI;AACF,UAAM,SAAS,IAAI,IAAI,UAAU,QAAQ,GAAG;AAC5C,UAAM,MAAM,UAAM,uBAAyB;AAAA,MACzC,KAAK,OAAO,SAAS;AAAA,IACvB,CAAC;AACD,WAAO;AAAA,EACT,SAAS,GAAG;AACV,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,SAAS,EAAE;AAAA,IACb;AAAA,EACF;AACF;AAbsB;AAetB,eAAsB,aAAa;AAAA,EACjC;AACF,GAEqD;AACnD,MAAI;AACF,UAAM,OAAO,UAAM,uBAAgC;AAAA,MACjD,KAAK,IAAI,IAAI,UAAU,WAAW,YAAY,EAAE,SAAS;AAAA,IAC3D,CAAC;AAED,WAAO;AAAA,MACL,IAAI;AAAA,MACJ;AAAA,IACF;AAAA,EACF,SAAS,KAAK;AACZ,W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;AACzC,QAAM,OAAqC;AAAA,IACzC;AAAA,IACA,MAAM,wBAAW,QAAQ;AAAA,EAC3B;AACA,QAAM,OAAO,UAAM,uBAAuC;AAAA,IACxD,KAAK,IAAI,IAAI,UAAU,SAAS,YAAY,EAAE,SAAS;AAAA,IACvD;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAhBsB;AAkBtB,eAAsB,eAAe;AAAA,EACnC;AAAA,EACA;AACF,GAG6B;AAC3B,QAAM,OAAO,UAAM,uBAAyB;AAAA,IAC1C,KAAK,IAAI,IAAI,UAAU,QAAQ,YAAY,EAAE,SAAS;AAAA,IACtD,MAAM;AAAA,EACR,CAAC;AACD,SAAO;AACT;AAZsB;","names":["import_utils"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/get-template-suggestions.ts"],"sourcesContent":["import { KsAppClientData, PluginsApi, KsRenderResults } from '@knapsack/types';\nimport type {\n GenericResponse,\n KsAppClientDataAndMeta,\n KsAppClientDataNoMeta,\n KsFileSaverParams,\n} from '@knapsack/types';\nimport { fetcher } from '@knapsack/utils';\nimport * as getTemplateSuggestions from './get-template-suggestions';\n\nexport { getTemplateSuggestions };\n\nexport interface KnapsackDataStoreSaveBody {\n state: KsAppClientData;\n}\n\nexport type PatternRenderData = {\n patternId: string;\n templateId: string;\n /**\n * Data id from `saveData()`\n * Cannot use with `demoId`\n */\n dataId?: string;\n /**\n * Cannot use with `dataId`\n */\n demoId?: string;\n assetSetId?: string;\n wrapHtml?: boolean;\n isInIframe?: boolean;\n cacheBuster?: string;\n};\n\nexport const ENDPOINTS = {\n health: '/api/v1/',\n dataStore: '/api/v1/data-store',\n dataStorePrep: '/api/v1/data-store-prep',\n files: '/api/v1/files',\n data: '/api/v1/data',\n render: '/api/v1/render',\n upload: '/api/v1/upload',\n plugins: '/api/v1/plugins',\n getTemplateSuggestions: getTemplateSuggestions.path,\n};\n\nexport async function checkAppClientUrl(url: string): Promise<GenericResponse> {\n try {\n const theUrl = new URL(ENDPOINTS.health, url); // will throw if url not formatted correctly\n const res = await fetcher<GenericResponse>({\n url: theUrl.toString(),\n });\n return res;\n } catch (e) {\n return {\n ok: false,\n message: e.message,\n };\n }\n}\n\nexport async function getDataStore({\n appClientUrl,\n}: {\n appClientUrl: string;\n}): Promise<GenericResponse<KsAppClientDataAndMeta>> {\n try {\n const data = await fetcher<KsAppClientDataAndMeta>({\n url: new URL(ENDPOINTS.dataStore, appClientUrl).toString(),\n });\n\n return {\n ok: true,\n data,\n };\n } catch (err) {\n return {\n ok: false,\n message: err.message,\n };\n }\n}\n\n// just need a function that can throw an error\nexport async function getAppClientData({\n appClientUrl,\n}: {\n appClientUrl: string;\n}): Promise<KsAppClientDataAndMeta> {\n const serverDataRes = await getDataStore({ appClientUrl });\n // console.log(`getDataStore() response`, serverDataRes);\n if (!serverDataRes.ok) {\n const message = `Could not load data from custom url \"${appClientUrl}\" ${serverDataRes.message}`;\n throw new Error(message);\n }\n return serverDataRes.data;\n}\n\n/** Sole job is to strip `metaState` if it's there */\nexport function prepAppClientData(\n state: KsAppClientData,\n): KsAppClientDataNoMeta {\n const { metaState, ...appClientDataNoMeta } = state;\n return appClientDataNoMeta;\n}\n\nexport async function prepareDataForFileSave({\n urlBase,\n state,\n}: {\n urlBase: string;\n state: KsAppClientDataNoMeta;\n}): Promise<GenericResponse<KsFileSaverParams>> {\n try {\n const body: KnapsackDataStoreSaveBody = {\n state: prepAppClientData(state),\n };\n const data = await fetcher<GenericResponse<KsFileSaverParams>>({\n url: new URL(ENDPOINTS.dataStorePrep, urlBase).toString(),\n body,\n });\n\n return data;\n } catch (err) {\n return {\n ok: false,\n message: err.message,\n };\n }\n}\n\nexport async function submitDataForFileSave({\n urlBase,\n state,\n}: {\n urlBase: string;\n state: KsAppClientDataNoMeta;\n}): Promise<void> {\n const appClientData = prepAppClientData(state);\n const body: KnapsackDataStoreSaveBody = {\n state: appClientData,\n };\n const data = await fetcher<GenericResponse>({\n url: new URL(ENDPOINTS.dataStore, urlBase).toString(),\n body,\n });\n\n if (!data.ok) {\n throw new Error(`Could not save data to localhost files: ${data.message}`);\n }\n}\n\nexport async function getPluginContent({\n pluginId,\n appClientUrl,\n}: {\n pluginId: string;\n appClientUrl: string;\n}): Promise<PluginsApi.GetContentResponse> {\n const body: PluginsApi.GetContentRequest = {\n pluginId,\n type: PluginsApi.ACTIONS.getContent,\n };\n const data = await fetcher<PluginsApi.GetContentResponse>({\n url: new URL(ENDPOINTS.plugins, appClientUrl).toString(),\n body,\n });\n return data;\n}\n\nexport async function renderTemplate({\n options,\n appClientUrl,\n}: {\n options: PatternRenderData;\n appClientUrl: string;\n}): Promise<KsRenderResults> {\n const data = await fetcher<KsRenderResults>({\n url: new URL(ENDPOINTS.render, appClientUrl).toString(),\n body: options,\n });\n return data;\n}\n","import type { TemplateSuggestionsGetFn } from '@knapsack/types';\nimport { fetcher } from '@knapsack/utils';\n\nexport const path = '/api/v1/template-suggestions';\nexport const method = 'GET';\nexport type ReqParams = Parameters<TemplateSuggestionsGetFn>[0];\nexport type ResBody =\n | {\n type: 'success';\n data: Awaited<ReturnType<TemplateSuggestionsGetFn>>;\n }\n | {\n type: 'error.invalidParams';\n message: string;\n }\n | {\n type: 'error.pathNotFound';\n message: string;\n }\n | {\n type: 'error.couldNotParse';\n message: string;\n };\n\nexport async function getTemplateSuggestions({\n appClientUrl,\n query,\n}: {\n appClientUrl: string;\n query: ReqParams;\n}): Promise<ResBody> {\n return fetcher<ResBody>({\n url: new URL(path, appClientUrl).toString(),\n query,\n });\n}\n"],"mappings":";;;;;;;;AAAA,SAA0B,kBAAmC;AAO7D,SAAS,WAAAA,gBAAe;;;ACPxB;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAS,eAAe;AAEjB,IAAM,OAAO;AACb,IAAM,SAAS;AAoBtB,eAAsB,uBAAuB;AAAA,EAC3C;AAAA,EACA;AACF,GAGqB;AACnB,SAAO,QAAiB;AAAA,IACtB,KAAK,IAAI,IAAI,MAAM,YAAY,EAA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version":3,"sources":["../src/index.ts","../src/get-template-suggestions.ts"],"sourcesContent":["import { KsAppClientData, PluginsApi } from '@knapsack/types';\nimport type {\n GenericResponse,\n KsAppClientDataAndMeta,\n KsAppClientDataNoMeta,\n KsFileSaverParams,\n} from '@knapsack/types';\nimport { fetcher } from '@knapsack/utils';\nimport * as getTemplateSuggestions from './get-template-suggestions';\n\nexport { getTemplateSuggestions };\n\nexport interface KnapsackDataStoreSaveBody {\n state: KsAppClientData;\n}\n\nexport interface KnapsackTemplateRendererResults {\n ok: boolean;\n html: string;\n usage?: string;\n templateLanguage?: string;\n message?: string;\n}\n\nexport interface KsRenderResults extends KnapsackTemplateRendererResults {\n wrappedHtml: string;\n}\n\nexport type PatternRenderData = {\n patternId: string;\n templateId: string;\n /**\n * Data id from `saveData()`\n * Cannot use with `demoId`\n */\n dataId?: string;\n /**\n * Cannot use with `dataId`\n */\n demoId?: string;\n assetSetId?: string;\n wrapHtml?: boolean;\n isInIframe?: boolean;\n cacheBuster?: string;\n};\n\nexport const ENDPOINTS = {\n health: '/api/v1/',\n dataStore: '/api/v1/data-store',\n dataStorePrep: '/api/v1/data-store-prep',\n files: '/api/v1/files',\n data: '/api/v1/data',\n render: '/api/v1/render',\n upload: '/api/v1/upload',\n plugins: '/api/v1/plugins',\n getTemplateSuggestions: getTemplateSuggestions.path,\n};\n\nexport async function checkAppClientUrl(url: string): Promise<GenericResponse> {\n try {\n const theUrl = new URL(ENDPOINTS.health, url); // will throw if url not formatted correctly\n const res = await fetcher<GenericResponse>({\n url: theUrl.toString(),\n });\n return res;\n } catch (e) {\n return {\n ok: false,\n message: e.message,\n };\n }\n}\n\nexport async function getDataStore({\n appClientUrl,\n}: {\n appClientUrl: string;\n}): Promise<GenericResponse<KsAppClientDataAndMeta>> {\n try {\n const data = await fetcher<KsAppClientDataAndMeta>({\n url: new URL(ENDPOINTS.dataStore, appClientUrl).toString(),\n });\n\n return {\n ok: true,\n data,\n };\n } catch (err) {\n return {\n ok: false,\n message: err.message,\n };\n }\n}\n\n// just need a function that can throw an error\nexport async function getAppClientData({\n appClientUrl,\n}: {\n appClientUrl: string;\n}): Promise<KsAppClientDataAndMeta> {\n const serverDataRes = await getDataStore({ appClientUrl });\n // console.log(`getDataStore() response`, serverDataRes);\n if (!serverDataRes.ok) {\n const message = `Could not load data from custom url \"${appClientUrl}\" ${serverDataRes.message}`;\n throw new Error(message);\n }\n return serverDataRes.data;\n}\n\n/** Sole job is to strip `metaState` if it's there */\nexport function prepAppClientData(\n state: KsAppClientData,\n): KsAppClientDataNoMeta {\n const { metaState, ...appClientDataNoMeta } = state;\n return appClientDataNoMeta;\n}\n\nexport async function prepareDataForFileSave({\n urlBase,\n state,\n}: {\n urlBase: string;\n state: KsAppClientDataNoMeta;\n}): Promise<GenericResponse<KsFileSaverParams>> {\n try {\n const body: KnapsackDataStoreSaveBody = {\n state: prepAppClientData(state),\n };\n const data = await fetcher<GenericResponse<KsFileSaverParams>>({\n url: new URL(ENDPOINTS.dataStorePrep, urlBase).toString(),\n body,\n });\n\n return data;\n } catch (err) {\n return {\n ok: false,\n message: err.message,\n };\n }\n}\n\nexport async function submitDataForFileSave({\n urlBase,\n state,\n}: {\n urlBase: string;\n state: KsAppClientDataNoMeta;\n}): Promise<void> {\n const appClientData = prepAppClientData(state);\n const body: KnapsackDataStoreSaveBody = {\n state: appClientData,\n };\n const data = await fetcher<GenericResponse>({\n url: new URL(ENDPOINTS.dataStore, urlBase).toString(),\n body,\n });\n\n if (!data.ok) {\n throw new Error(`Could not save data to localhost files: ${data.message}`);\n }\n}\n\nexport async function getPluginContent({\n pluginId,\n appClientUrl,\n}: {\n pluginId: string;\n appClientUrl: string;\n}): Promise<PluginsApi.GetContentResponse> {\n const body: PluginsApi.GetContentRequest = {\n pluginId,\n type: PluginsApi.ACTIONS.getContent,\n };\n const data = await fetcher<PluginsApi.GetContentResponse>({\n url: new URL(ENDPOINTS.plugins, appClientUrl).toString(),\n body,\n });\n return data;\n}\n\nexport async function renderTemplate({\n options,\n appClientUrl,\n}: {\n options: PatternRenderData;\n appClientUrl: string;\n}): Promise<KsRenderResults> {\n const data = await fetcher<KsRenderResults>({\n url: new URL(ENDPOINTS.render, appClientUrl).toString(),\n body: options,\n });\n return data;\n}\n","import type { TemplateSuggestionsGetFn } from '@knapsack/types';\nimport { fetcher } from '@knapsack/utils';\n\nexport const path = '/api/v1/template-suggestions';\nexport const method = 'GET';\nexport type ReqParams = Parameters<TemplateSuggestionsGetFn>[0];\nexport type ResBody =\n | {\n type: 'success';\n data: Awaited<ReturnType<TemplateSuggestionsGetFn>>;\n }\n | {\n type: 'error.invalidParams';\n message: string;\n }\n | {\n type: 'error.pathNotFound';\n message: string;\n }\n | {\n type: 'error.couldNotParse';\n message: string;\n };\n\nexport async function getTemplateSuggestions({\n appClientUrl,\n query,\n}: {\n appClientUrl: string;\n query: ReqParams;\n}): Promise<ResBody> {\n return fetcher<ResBody>({\n url: new URL(path, appClientUrl).toString(),\n query,\n });\n}\n"],"mappings":";;;;;;;;AAAA,SAA0B,kBAAkB;AAO5C,SAAS,WAAAA,gBAAe;;;ACPxB;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAS,eAAe;AAEjB,IAAM,OAAO;AACb,IAAM,SAAS;AAoBtB,eAAsB,uBAAuB;AAAA,EAC3C;AAAA,EACA;AACF,GAGqB;AACnB,SAAO,QAAiB;AAAA,IACtB,KAAK,IAAI,IAAI,MAAM,YAAY,EAAE,SAAS;AAAA,IAC1C;AAAA,EACF,CAAC;AACH;AAXsB;;;ADsBf,IAAM,YAAY;AAAA,EACvB,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,eAAe;AAAA,EACf,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,wBAA+C;AACjD;AAEA,eAAsB,kBAAkB,KAAuC;AAC7E,MAAI;AACF,UAAM,SAAS,IAAI,IAAI,UAAU,QAAQ,GAAG;AAC5C,UAA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AvBsB;AAyBtB,eAAsB,sBAAsB;AAAA,EAC1C;AAAA,EACA;AACF,GAGkB;AAChB,QAAM,gBAAgB,kBAAkB,KAAK;AAC7C,QAAM,OAAkC;AAAA,IACtC,OAAO;AAAA,EACT;AACA,QAAM,OAAO,MAAMA,SAAyB;AAAA,IAC1C,KAAK,IAAI,IAAI,UAAU,WAAW,OAAO,EAAE,SAAS;AAAA,IACpD;AAAA,EACF,CAAC;AAED,MAAI,CAAC,KAAK,IAAI;AACZ,UAAM,IAAI,MAAM,2CAA2C,KAAK,OAAO,EAAE;AAAA,EAC3E;AACF;AAnBsB;AAqBtB,eAAsB,iBAAiB;AAAA,EACrC;AAAA,EACA;AACF,GAG2C;AACzC,QAAM,OAAqC;AAAA,IACzC;AAAA,IACA,MAAM,WAAW,QAAQ;AAAA,EAC3B;AACA,QAAM,OAAO,MAAMA,SAAuC;AAAA,IACxD,KAAK,IAAI,IAAI,UAAU,SAAS,YAAY,EAAE,SAAS;AAAA,IACvD;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAhBsB;AAkBtB,eAAsB,eAAe;AAAA,EACnC;AAAA,EACA;AACF,GAG6B;AAC3B,QAAM,OAAO,MAAMA,SAAyB;AAAA,IAC1C,KAAK,IAAI,IAAI,UAAU,QAAQ,YAAY,EAAE,SAAS;AAAA,IACtD,MAAM;AAAA,EACR,CAAC;AACD,SAAO;AACT;AAZsB;","names":["fetcher","fetcher"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@knapsack/app-client-api",
3
3
  "description": "",
4
- "version": "4.69.8--canary.4746.1acd21a.0",
4
+ "version": "4.69.8--canary.4532.626b8d9.0",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
@@ -23,14 +23,14 @@
23
23
  "lint": "eslint ./"
24
24
  },
25
25
  "dependencies": {
26
- "@knapsack/types": "4.69.8--canary.4746.1acd21a.0",
27
- "@knapsack/utils": "4.69.8--canary.4746.1acd21a.0",
26
+ "@knapsack/types": "4.69.8--canary.4532.626b8d9.0",
27
+ "@knapsack/utils": "4.69.8--canary.4532.626b8d9.0",
28
28
  "cross-fetch": "^4.0.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@knapsack/eslint-config-starter": "4.69.8--canary.4746.1acd21a.0",
32
- "@knapsack/prettier-config": "4.69.8--canary.4746.1acd21a.0",
33
- "@knapsack/typescript-config-starter": "4.69.8--canary.4746.1acd21a.0",
31
+ "@knapsack/eslint-config-starter": "4.69.8--canary.4532.626b8d9.0",
32
+ "@knapsack/prettier-config": "4.69.8--canary.4532.626b8d9.0",
33
+ "@knapsack/typescript-config-starter": "4.69.8--canary.4532.626b8d9.0",
34
34
  "@types/node": "^20.16.5",
35
35
  "eslint": "^8.57.0",
36
36
  "tsup": "^8.2.4",
@@ -45,5 +45,5 @@
45
45
  "directory": "libs/app-client-api",
46
46
  "type": "git"
47
47
  },
48
- "gitHead": "1acd21afebda789b7b487bdf358dd0ab6bd44da0"
48
+ "gitHead": "626b8d9a307f58803dbb1f103373c76e8898cfd1"
49
49
  }