@dosgato/templating 0.0.109 → 0.0.110

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/render.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ContextBase, DataData, PageData, PageRecord, PageRecordOptionalData } from './component.js';
2
- import { AssetLink, DataFolderLink, DataLink, LinkDefinition, PageLink } from './links.js';
2
+ import { AssetFolderLink, AssetLink, DataFolderLink, DataLink, LinkDefinition, PageLink } from './links.js';
3
3
  export declare function printHeader(ctx: ContextBase, content: string | undefined | null, attributes?: Record<string, string>): string;
4
4
  export declare function advanceHeader<T extends ContextBase>(ctx: T, content: string | undefined | null): T;
5
5
  export interface PictureResize {
@@ -31,6 +31,17 @@ export interface PictureAttributes {
31
31
  widths: PictureResize[];
32
32
  }[];
33
33
  }
34
+ export interface AssetRecord {
35
+ id: string;
36
+ path: string;
37
+ checksum: string;
38
+ name: string;
39
+ extension: string;
40
+ filename: string;
41
+ mime: string;
42
+ downloadLink: string;
43
+ image?: PictureAttributes;
44
+ }
34
45
  export interface PageForNavigation {
35
46
  id: string;
36
47
  name: string;
@@ -91,6 +102,21 @@ export interface APIClient {
91
102
  absolute?: boolean;
92
103
  extension?: string;
93
104
  }) => string | undefined;
105
+ /**
106
+ * Get assets by link
107
+ *
108
+ * Certain components will be presenting download links for assets instead of showing images inline. In
109
+ * those cases, you can use this function instead of getImgAttributes. The result you would get from
110
+ * getImgAttributes will be inside the `image` property.
111
+ *
112
+ * It returns an array of assets because if you provide a link to an asset folder the result will be an
113
+ * array. So if you provide an asset link you will just get an array of length 1. The recursive parameter
114
+ * is available if you prefer to receive all assets that descend from the given folder instead of direct child
115
+ * assets.
116
+ *
117
+ * Will be dataloaded so you can safely use this in a Promise.all.
118
+ */
119
+ getAssetsByLink: (link: AssetLink | AssetFolderLink | string, recursive?: boolean) => Promise<AssetRecord[]>;
94
120
  /**
95
121
  * This function will retrieve information about an image to help you construct responsive HTML
96
122
  * for a <picture> element including the <img> and all <source> tags.
@@ -99,7 +125,7 @@ export interface APIClient {
99
125
  * text gathered from a template's dialog should generally take precedence (though the dialog may
100
126
  * preload the alt text field with the asset repository default).
101
127
  *
102
- * Will be dataloaded.
128
+ * Will be dataloaded so you can safely use this in a Promise.all.
103
129
  */
104
130
  getImgAttributes: (link: string | AssetLink | undefined, absolute?: boolean) => Promise<PictureAttributes | undefined>;
105
131
  /** Get the data for a specific page.
@@ -120,5 +120,5 @@ export interface DialogPageProp {
120
120
  * A function you may use in your dialogs to make an authenticated graphql request to the DosGato
121
121
  * API.
122
122
  */
123
- export declare function dialogQuery<T = any>(query: string, variables: any): Promise<T>;
123
+ export declare function dialogQuery<T = any>(query: string, variables?: any): Promise<T>;
124
124
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosgato/templating",
3
- "version": "0.0.109",
3
+ "version": "0.0.110",
4
4
  "description": "A library to support building templates for dosgato CMS.",
5
5
  "type": "module",
6
6
  "exports": {