@uniformdev/project-map 17.3.1-alpha.194

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.
@@ -0,0 +1,92 @@
1
+ import { ApiClient } from '@uniformdev/context/api';
2
+ import { SitemapNodeUpsertRequest, SitemapNodeUpsertRequestNode, SitemapNodeDeleteRequest, SitemapNodeGetRequest, SitemapNodeGetResponse, SitemapNode, SitemapNodeWithId, SitemapGetRequest, SitemapGetResponse, SitemapUpsertRequest, SitemapDeleteRequest, SitemapDefinition, SitemapDefinitionWithId, SitemapUpsertResponse } from '@uniformdev/sitemap';
3
+
4
+ declare type ProjectMapNodeWithProjectMapReference = ProjectMapNodeWithId & {
5
+ projectMapId: string;
6
+ };
7
+
8
+ declare type ProjectMapNodeUpsertRequest = Omit<SitemapNodeUpsertRequest, 'sitemapId'> & {
9
+ projectMapId: string;
10
+ };
11
+ declare type ProjectMapNodeUpsertRequestNode = SitemapNodeUpsertRequestNode;
12
+ declare type ProjectMapNodeDeleteRequest = Omit<SitemapNodeDeleteRequest, 'sitemapId'> & {
13
+ projectMapId: string;
14
+ };
15
+ declare type ProjectMapNodeGetRequest = Omit<SitemapNodeGetRequest, 'sitemapId'> & {
16
+ projectMapId: string;
17
+ };
18
+ declare type ProjectMapNodeGetResponse = SitemapNodeGetResponse;
19
+ declare type ProjectMapNode = SitemapNode;
20
+ declare type ProjectMapNodeWithId = SitemapNodeWithId;
21
+ declare type ProjectMapGetRequest = Omit<SitemapGetRequest, 'sitemapId'> & {
22
+ projectMapId: string;
23
+ };
24
+ declare type ProjectMapGetResponse = SitemapGetResponse;
25
+ declare type ProjectMapUpsertRequest = Omit<SitemapUpsertRequest, 'sitemap'> & {
26
+ projectMap: SitemapUpsertRequest['sitemap'];
27
+ };
28
+ declare type ProjectMapDeleteRequest = Omit<SitemapDeleteRequest, 'sitemapId'> & {
29
+ projectMapId: string;
30
+ };
31
+ declare type ProjectMapDefinition = SitemapDefinition;
32
+ declare type ProjectMapDefinitionWithId = SitemapDefinitionWithId;
33
+ declare type ProjectMapUpsertResponse = SitemapUpsertResponse;
34
+ declare type NodeType = 'placeholder' | 'composition' | 'redirect';
35
+ declare type ProjectMapDefinitions = {
36
+ projectMaps: ProjectMapDefinitionWithId[];
37
+ projectMapNodes: ProjectMapNodeWithProjectMapReference[];
38
+ };
39
+
40
+ declare const ROOT_NODE_PATH = "/";
41
+ declare type ProjectMapClientOptions = {
42
+ /** The Uniform API host to use. Internal use. */
43
+ apiHost?: string;
44
+ /** The Uniform API key to use when sending API requests. This or bearer token must be specified. */
45
+ apiKey?: string | undefined;
46
+ /** The Uniform bearer token to use. Internal use. */
47
+ bearerToken?: string | undefined;
48
+ /** Specify a fetch implementation to use when fetching data. Useful if you want to only polyfill selectively. */
49
+ fetch?: typeof fetch;
50
+ /** Specify whether caching is disabled. */
51
+ bypassCache?: boolean;
52
+ };
53
+ declare type ProjectMapSubtree = ProjectMapNode & {
54
+ children?: Array<ProjectMapSubtree> | undefined;
55
+ parent?: ProjectMapSubtree | undefined;
56
+ previousSibling?: ProjectMapSubtree | undefined;
57
+ nextSibling?: ProjectMapSubtree | undefined;
58
+ };
59
+ declare class ProjectMapClient extends ApiClient<ProjectMapClientOptions> {
60
+ constructor(options: ProjectMapClientOptions);
61
+ fetchProjectMapDefinitions: (projectId: string) => Promise<{
62
+ sitemaps: {
63
+ id?: string | undefined;
64
+ name: string;
65
+ description?: string | undefined;
66
+ baseUrl?: string | undefined;
67
+ default?: boolean | undefined;
68
+ }[];
69
+ }>;
70
+ fetchProjectMapDefinition: (options: ProjectMapGetRequest) => Promise<{
71
+ sitemaps: {
72
+ id?: string | undefined;
73
+ name: string;
74
+ description?: string | undefined;
75
+ baseUrl?: string | undefined;
76
+ default?: boolean | undefined;
77
+ }[];
78
+ }>;
79
+ upsertProjectMap: (options: ProjectMapUpsertRequest) => Promise<string>;
80
+ deleteProjectMap: (options: ProjectMapDeleteRequest) => Promise<void>;
81
+ upsertProjectMapNodes: (options: ProjectMapNodeUpsertRequest) => Promise<void>;
82
+ deleteProjectMapNode: (options: ProjectMapNodeDeleteRequest) => Promise<void>;
83
+ fetchSubtree: (options: ProjectMapNodeGetRequest) => Promise<ProjectMapSubtree | undefined>;
84
+ fetchNodes: (options: ProjectMapNodeGetRequest) => Promise<ProjectMapNodeGetResponse>;
85
+ private cleanProjectMapNode;
86
+ private validatePath;
87
+ }
88
+ declare class UncachedProjectMapClient extends ProjectMapClient {
89
+ constructor(options: Omit<ProjectMapClientOptions, 'bypassCache'>);
90
+ }
91
+
92
+ export { NodeType, ProjectMapClient, ProjectMapClientOptions, ProjectMapDefinition, ProjectMapDefinitionWithId, ProjectMapDefinitions, ProjectMapDeleteRequest, ProjectMapGetRequest, ProjectMapGetResponse, ProjectMapNode, ProjectMapNodeDeleteRequest, ProjectMapNodeGetRequest, ProjectMapNodeGetResponse, ProjectMapNodeUpsertRequest, ProjectMapNodeUpsertRequestNode, ProjectMapNodeWithId, ProjectMapSubtree, ProjectMapUpsertRequest, ProjectMapUpsertResponse, ROOT_NODE_PATH, UncachedProjectMapClient };
@@ -0,0 +1 @@
1
+ import{g as o,h as r,i as e}from"./chunk-QOYLUYYN.mjs";export{r as ProjectMapClient,o as ROOT_NODE_PATH,e as UncachedProjectMapClient};
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var u=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var R=(a,i)=>{for(var e in i)u(a,e,{get:i[e],enumerable:!0})},y=(a,i,e,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of m(i))!N.call(a,r)&&r!==e&&u(a,r,{get:()=>i[r],enumerable:!(t=l(i,r))||t.enumerable});return a};var U=a=>y(u({},"__esModule",{value:!0}),a);var g={};R(g,{ProjectMapClient:()=>n,ROOT_NODE_PATH:()=>b,UncachedProjectMapClient:()=>j});module.exports=U(g);var P=require("@uniformdev/context/api"),b="/",n=class extends P.ApiClient{constructor(e){super(e);this.fetchProjectMapDefinitions=async e=>{let t=this.createUrl("/api/v1/sitemap",{projectId:e});return await this.apiClient(t)};this.fetchProjectMapDefinition=async e=>{let t=this.createUrl("/api/v1/sitemap",{...e,sitemapId:e.projectMapId});return await this.apiClient(t)};this.upsertProjectMap=async e=>{let t=this.createUrl("/api/v1/sitemap");return(await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,sitemap:e.projectMap,projectMap:void 0})})).sitemapId};this.deleteProjectMap=async e=>{let t=this.createUrl("/api/v1/sitemap");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,sitemapId:e.projectMapId,projectMapId:void 0}),expectNoContent:!0})};this.upsertProjectMapNodes=async e=>{let t=this.createUrl("/api/v1/sitemap-nodes");await this.apiClient(t,{method:"PUT",body:JSON.stringify({projectId:e.projectId,sitemapId:e.projectMapId,nodes:e.nodes.map(r=>({...r,node:{...this.cleanProjectMapNode(r.node)}}))}),expectNoContent:!0})};this.deleteProjectMapNode=async e=>{let t=this.createUrl("/api/v1/sitemap-nodes");(!e.path||this.validatePath(e.path))&&await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,sitemapId:e.projectMapId}),expectNoContent:!0})};this.fetchSubtree=async e=>{var M;let t={};t.projectId=e.projectId,e.projectMapId&&(t.sitemapId=e.projectMapId),e.path&&this.validatePath(e.path)&&(t.path=e.path),e.depth&&(t.depth=e.depth.toString()),t.tree="true";let r=this.createUrl("/api/v1/sitemap-nodes",t),f={...(await this.apiClient(r)).tree},s=[f];for(;s&&s.length>0;){let c=s.pop(),o;(M=c==null?void 0:c.children)==null||M.forEach(p=>{p.parent=h(c),p.previousSibling=h(o),o&&(o.nextSibling=h(p)),o=p,s.push(p)})}return f};this.fetchNodes=async e=>{let t={};t.projectId=e.projectId,e.projectMapId&&(t.sitemapId=e.projectMapId),e.path&&this.validatePath(e.path)&&(t.path=e.path),e.id&&(t.id=e.id),e.limit&&(t.limit=e.limit.toString()),e.offset&&(t.offset=e.offset.toString());let r=this.createUrl("/api/v1/sitemap-nodes",t);return await this.apiClient(r)}}cleanProjectMapNode(e){var t,r,d;return{id:((d=(r=(t=e.id)==null?void 0:t.match(/^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i))==null?void 0:r.length)!=null?d:0)==1?e.id:void 0,path:e.path,name:e.name,type:e.type,compositionId:e.compositionId,description:e.description}}validatePath(e){let t=/[*%!&@]/g;if(e==null?void 0:e.match(t))throw"path cannot contain reserved characters * % ! & @";return!0}},j=class extends n{constructor(i){super({...i,bypassCache:!0})}},h=a=>a?{...a,parent:void 0,children:void 0}:void 0;0&&(module.exports={ProjectMapClient,ROOT_NODE_PATH,UncachedProjectMapClient});
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import{g as o,h as r,i as e}from"./chunk-QOYLUYYN.mjs";export{r as ProjectMapClient,o as ROOT_NODE_PATH,e as UncachedProjectMapClient};
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@uniformdev/project-map",
3
+ "version": "17.3.1-alpha.194+213d546fd",
4
+ "description": "Uniform Sitemap",
5
+ "license": "SEE LICENSE IN LICENSE.txt",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.esm.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "node": "./dist/index.mjs",
12
+ "default": "./dist/index.esm.js"
13
+ },
14
+ "require": "./dist/index.js"
15
+ },
16
+ "./cli": {
17
+ "types": "./dist/cli/cli.d.ts",
18
+ "import": "./dist/cli/cli.mjs",
19
+ "require": "./dist/cli/cli.js"
20
+ }
21
+ },
22
+ "types": "./dist/index.d.ts",
23
+ "typesVersions": {
24
+ "*": {
25
+ "*": [
26
+ "./dist/index.d.ts"
27
+ ],
28
+ "cli": [
29
+ "./dist/cli/cli.d.ts"
30
+ ]
31
+ }
32
+ },
33
+ "sideEffects": false,
34
+ "scripts": {
35
+ "build": "run-s build:ts",
36
+ "build:ts": "tsup --minify",
37
+ "dev": "run-s dev:ts",
38
+ "dev:ts": "tsup --watch",
39
+ "clean": "rimraf dist",
40
+ "test": "jest --maxWorkers=1 --passWithNoTests",
41
+ "lint": "eslint \"src/**/*.{js,ts,tsx}\"",
42
+ "format": "prettier --write \"src/**/*.{js,ts,tsx}\""
43
+ },
44
+ "files": [
45
+ "/dist"
46
+ ],
47
+ "dependencies": {
48
+ "@uniformdev/canvas": "^17.3.1-alpha.194+213d546fd",
49
+ "@uniformdev/context": "^17.3.1-alpha.194+213d546fd",
50
+ "@uniformdev/sitemap": "^17.3.1-alpha.194+213d546fd",
51
+ "p-limit": "^3.1.0"
52
+ },
53
+ "devDependencies": {
54
+ "@types/yargs": "17.0.13",
55
+ "@uniformdev/cli": "^17.3.1-alpha.194+213d546fd",
56
+ "yargs": "17.6.0"
57
+ },
58
+ "publishConfig": {
59
+ "access": "public"
60
+ },
61
+ "gitHead": "213d546fdfd0eb7482a220be62a91093b6925eb3"
62
+ }