@dosgato/templating 0.0.109 → 0.0.111

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,19 @@ 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
+ size: number;
43
+ meta: any;
44
+ downloadLink: string;
45
+ image?: PictureAttributes;
46
+ }
34
47
  export interface PageForNavigation {
35
48
  id: string;
36
49
  name: string;
@@ -91,6 +104,21 @@ export interface APIClient {
91
104
  absolute?: boolean;
92
105
  extension?: string;
93
106
  }) => string | undefined;
107
+ /**
108
+ * Get assets by link
109
+ *
110
+ * Certain components will be presenting download links for assets instead of showing images inline. In
111
+ * those cases, you can use this function instead of getImgAttributes. The result you would get from
112
+ * getImgAttributes will be inside the `image` property.
113
+ *
114
+ * It returns an array of assets because if you provide a link to an asset folder the result will be an
115
+ * array. So if you provide an asset link you will just get an array of length 1. The recursive parameter
116
+ * is available if you prefer to receive all assets that descend from the given folder instead of direct child
117
+ * assets.
118
+ *
119
+ * Will be dataloaded so you can safely use this in a Promise.all.
120
+ */
121
+ getAssetsByLink: (link: AssetLink | AssetFolderLink | string, recursive?: boolean) => Promise<AssetRecord[]>;
94
122
  /**
95
123
  * This function will retrieve information about an image to help you construct responsive HTML
96
124
  * for a <picture> element including the <img> and all <source> tags.
@@ -99,7 +127,7 @@ export interface APIClient {
99
127
  * text gathered from a template's dialog should generally take precedence (though the dialog may
100
128
  * preload the alt text field with the asset repository default).
101
129
  *
102
- * Will be dataloaded.
130
+ * Will be dataloaded so you can safely use this in a Promise.all.
103
131
  */
104
132
  getImgAttributes: (link: string | AssetLink | undefined, absolute?: boolean) => Promise<PictureAttributes | undefined>;
105
133
  /** 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.111",
4
4
  "description": "A library to support building templates for dosgato CMS.",
5
5
  "type": "module",
6
6
  "exports": {