@twotaps/site-utils
Advanced tools
Comparing version 0.0.12 to 0.0.13
@@ -0,1 +1,8 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
// @generated | ||
// This file was automatically generated and should not be edited. | ||
//============================================================== | ||
// START Enums and Input Objects | ||
//============================================================== | ||
export var TTSchemaFieldType; | ||
@@ -10,2 +17,4 @@ (function (TTSchemaFieldType) { | ||
})(TTSchemaFieldType || (TTSchemaFieldType = {})); | ||
//# sourceMappingURL=globalTypes.js.map | ||
//============================================================== | ||
// END Enums and Input Objects | ||
//============================================================== |
@@ -0,2 +1,4 @@ | ||
// Intentinally left blank | ||
export * from './page/index.js'; | ||
//# sourceMappingURL=index.js.map | ||
export * from './components/index.js'; |
@@ -0,2 +1,5 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
// @generated | ||
// This file was automatically generated and should not be edited. | ||
export {}; | ||
//# sourceMappingURL=AssetList.js.map |
@@ -1,2 +0,2 @@ | ||
import { TTSchemaFieldType } from "../../__generated__/globalTypes"; | ||
import type { TTSchemaFieldType } from "../../__generated__/globalTypes"; | ||
export interface Page_page_publishedRevision_schema_properties { | ||
@@ -35,2 +35,5 @@ __typename: "PageRevisionSchemaProperties"; | ||
id: number; | ||
/** | ||
* Technical name | ||
*/ | ||
name: string; | ||
@@ -44,2 +47,5 @@ titlePlural: string; | ||
id: number; | ||
/** | ||
* Technical name | ||
*/ | ||
name: string; | ||
@@ -46,0 +52,0 @@ titlePlural: string; |
@@ -0,2 +1,5 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
// @generated | ||
// This file was automatically generated and should not be edited. | ||
export {}; | ||
//# sourceMappingURL=Page.js.map |
export * from './page.dto.js'; | ||
export * from './page.service.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -36,3 +36,3 @@ export declare class AssetDto { | ||
} | ||
export interface TTSchemaProperties { | ||
export declare class TTSchemaProperties { | ||
fieldId: number; | ||
@@ -39,0 +39,0 @@ name: string; |
@@ -13,4 +13,5 @@ export class AssetDto { | ||
} | ||
export class TTSchemaProperties { | ||
} | ||
export class TTSchemaCustomDto extends TTSchemaDto { | ||
} | ||
//# sourceMappingURL=page.dto.js.map |
@@ -68,2 +68,1 @@ import { gql } from "@urql/core"; | ||
`; | ||
//# sourceMappingURL=page.query.js.map |
@@ -1,5 +0,12 @@ | ||
import { TTSchemaProperties } from "./page.dto.js"; | ||
import { PageDto } from "./page.dto.js"; | ||
import { Page_page, Page_page_publishedRevision_schema_ttschema_fields, Page_page_publishedRevision_schema_ttschema_subSchemas } from "./__generated__/Page"; | ||
import type { Page_page, Page_page_publishedRevision_schema_ttschema_fields, Page_page_publishedRevision_schema_ttschema_subSchemas } from "./__generated__/Page"; | ||
import type { TTSchemaProperties } from "./page.dto.js"; | ||
import type { PageDto } from "./page.dto.js"; | ||
export declare function getComponentsDictFromModules(modules: any): {}; | ||
/** | ||
* Map properties to their names. | ||
* This helps particularly for the components enable auto-completion to work seemlessly | ||
* | ||
* @param properties Array of properties | ||
* @returns Name-Value mapped property | ||
*/ | ||
export declare function propertyMapping(properties: TTSchemaProperties[], fields: Page_page_publishedRevision_schema_ttschema_fields[], schemas: Page_page_publishedRevision_schema_ttschema_subSchemas[]): {}; | ||
@@ -6,0 +13,0 @@ export declare class PageService { |
@@ -1,12 +0,1 @@ | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
import { Client } from "@urql/core"; | ||
@@ -29,2 +18,3 @@ import { GET_PAGE } from "./page.query.js"; | ||
} | ||
// Import available components in components | ||
export function getComponentsDictFromModules(modules) { | ||
@@ -40,2 +30,9 @@ let components = {}; | ||
} | ||
/** | ||
* Map properties to their names. | ||
* This helps particularly for the components enable auto-completion to work seemlessly | ||
* | ||
* @param properties Array of properties | ||
* @returns Name-Value mapped property | ||
*/ | ||
export function propertyMapping(properties, fields, schemas) { | ||
@@ -47,8 +44,12 @@ let flattenedProperties = {}; | ||
for (let prop of curProps) { | ||
// For each property, find the field | ||
let field = curFields.find((_field) => _field.id === prop.fieldId); | ||
// If the field is simple, add the value to the current level object by field name | ||
if ([TTSchemaFieldType.Text, TTSchemaFieldType.Image].includes(field.type)) { | ||
curFlattenedProps[field.name] = field.hasMultipleValues ? prop.value : prop.value[0]; | ||
// If the field is Schema type, recursively add | ||
} | ||
else if (field.type === TTSchemaFieldType.Text) { | ||
curFlattenedProps[field.name] = field.hasMultipleValues ? prop.value : prop.value[0]; | ||
// If the field is Schema type, recursively add | ||
} | ||
@@ -77,2 +78,3 @@ else if (field.type === TTSchemaFieldType.Schema) { | ||
this.assetIds = []; | ||
// Default to using the ltnetwork graphql server. | ||
let resolvedURI = uri ? uri : 'https://api-duo.twotaps.io/graphql'; | ||
@@ -83,6 +85,13 @@ this.apolloClient = new Client({ url: resolvedURI }); | ||
try { | ||
const { data } = await this.apolloClient. | ||
console.log(slug, domain); | ||
const { data, error } = await this.apolloClient. | ||
query(GET_PAGE, { slug, domain }). | ||
toPromise(); | ||
return this.parseResponse(data.page); | ||
if (data) { | ||
return this.parseResponse(data.page); | ||
} | ||
else { | ||
console.log(error); | ||
throw new Error('Unable to load page from API'); | ||
} | ||
} | ||
@@ -95,9 +104,19 @@ catch (err) { | ||
async parseResponse(page) { | ||
const { publishedRevision } = page, rest = __rest(page, ["publishedRevision"]); | ||
const { publishedRevision, ...rest } = page; | ||
let schema = publishedRevision.schema.reduce((accum, current) => { | ||
return ([...accum, Object.assign(Object.assign({}, current.ttschema), { id: current.id, ttschemaId: current.ttschema.id, sortOrder: current.sortOrder, properties: propertyMapping(current.properties, current.ttschema.fields, current.ttschema.subSchemas) })]); | ||
return ([...accum, { | ||
...current.ttschema, | ||
id: current.id, | ||
ttschemaId: current.ttschema.id, | ||
sortOrder: current.sortOrder, | ||
properties: propertyMapping(current.properties, current.ttschema.fields, current.ttschema.subSchemas), | ||
}]); | ||
}, []); | ||
return Object.assign(Object.assign({}, rest), { id: page.id, properties: {}, ttschema: schema.sort((first, second) => first.sortOrder - second.sortOrder) }); | ||
return { | ||
...rest, | ||
id: page.id, | ||
properties: {}, | ||
ttschema: schema.sort((first, second) => first.sortOrder - second.sortOrder), | ||
}; | ||
} | ||
} | ||
//# sourceMappingURL=page.service.js.map |
{ | ||
"name": "@twotaps/site-utils", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"description": "This package provides helper code for building twotaps public sites", | ||
@@ -17,3 +17,3 @@ "main": "dist/index.js", | ||
"pre:build": "yarn generate-schema", | ||
"prepublish": "yarn clean && yarn build", | ||
"prepublish": "yarn clean && yarn build && yarn svelte-kit package", | ||
"clean": "rm -rf dist", | ||
@@ -32,7 +32,5 @@ "build": "yarn tsc --build tsconfig.json", | ||
"@graphql-codegen/typescript-graphql-files-modules": "2.1.0", | ||
"ts-node": "^10.4.0", | ||
"typescript": "^4.5.4", | ||
"yml": "^1.0.0" | ||
}, | ||
"dependencies": { | ||
"@sveltejs/adapter-auto": "next", | ||
"@sveltejs/kit": "next", | ||
"@twotaps/template-editor-bridge": "^0.0.10", | ||
"@urql/core": "^2.4.4", | ||
@@ -43,4 +41,13 @@ "axios": "^0.24.0", | ||
"graphql": "^16.4.0", | ||
"path": "^0.12.7" | ||
"path": "^0.12.7", | ||
"svelte": "^3.44.0", | ||
"svelte-check": "^2.2.6", | ||
"svelte-preprocess": "^4.10.1", | ||
"svelte2tsx": "^0.5.9", | ||
"ts-node": "^10.4.0", | ||
"tslib": "^2.3.1", | ||
"typescript": "^4.5.4", | ||
"yml": "^1.0.0" | ||
}, | ||
"dependencies": {}, | ||
"repository": { | ||
@@ -47,0 +54,0 @@ "type": "git", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
20827
0
25
461
1
4
22
- Removed@urql/core@^2.4.4
- Removedaxios@^0.24.0
- Removedchalk@^5.0.0
- Removedfs@^0.0.1-security
- Removedgraphql@^16.4.0
- Removedpath@^0.12.7
- Removed@graphql-typed-document-node/core@3.2.0(transitive)
- Removed@urql/core@2.6.1(transitive)
- Removedaxios@0.24.0(transitive)
- Removedchalk@5.3.0(transitive)
- Removedfollow-redirects@1.15.9(transitive)
- Removedfs@0.0.1-security(transitive)
- Removedgraphql@16.9.0(transitive)
- Removedinherits@2.0.3(transitive)
- Removedpath@0.12.7(transitive)
- Removedprocess@0.11.10(transitive)
- Removedutil@0.10.4(transitive)
- Removedwonka@4.0.15(transitive)