🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

prismic-ts-codegen

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prismic-ts-codegen - npm Package Compare versions

Comparing version

to
0.0.4

102

dist/index.js

@@ -146,2 +146,5 @@ import { Project } from 'ts-morph';

}
if (config.tabName) {
config.writer.writeLine(`- **Tab**: ${config.tabName}`);
}
if (config.documentationURL) {

@@ -178,2 +181,3 @@ config.writer.writeLine(`- **Documentation**: ${config.documentationURL}`);

apiIDPath,
tabName: config.tabName,
documentationURL: getFieldDocumentationURL({ model: config.model })

@@ -194,3 +198,3 @@ });

const addInterfacePropertyFromField = (config) => {
const addInterfacePropertyForField = (config) => {
switch (config.model.type) {

@@ -207,3 +211,4 @@ case "UID": {

model: config.model,
path: config.path
path: config.path,
tabName: config.tabName
})

@@ -220,3 +225,4 @@ });

model: config.model,
path: config.path
path: config.path,
tabName: config.tabName
})

@@ -233,3 +239,4 @@ });

model: config.model,
path: config.path
path: config.path,
tabName: config.tabName
})

@@ -253,3 +260,4 @@ });

model: config.model,
path: config.path
path: config.path,
tabName: config.tabName
})

@@ -266,3 +274,4 @@ });

model: config.model,
path: config.path
path: config.path,
tabName: config.tabName
})

@@ -281,3 +290,4 @@ });

model: config.model,
path: config.path
path: config.path,
tabName: config.tabName
})

@@ -292,3 +302,4 @@ });

model: config.model,
path: config.path
path: config.path,
tabName: config.tabName
})

@@ -307,3 +318,4 @@ });

model: config.model,
path: config.path
path: config.path,
tabName: config.tabName
})

@@ -322,3 +334,4 @@ });

model: config.model,
path: config.path
path: config.path,
tabName: config.tabName
})

@@ -335,3 +348,4 @@ });

model: config.model,
path: config.path
path: config.path,
tabName: config.tabName
})

@@ -348,3 +362,4 @@ });

model: config.model,
path: config.path
path: config.path,
tabName: config.tabName
})

@@ -363,3 +378,4 @@ });

model: config.model,
path: config.path
path: config.path,
tabName: config.tabName
})

@@ -378,3 +394,4 @@ });

model: config.model,
path: config.path
path: config.path,
tabName: config.tabName
})

@@ -389,3 +406,4 @@ });

model: config.model,
path: config.path
path: config.path,
tabName: config.tabName
})

@@ -406,3 +424,4 @@ });

model: config.model,
path: config.path
path: config.path,
tabName: config.tabName
})

@@ -417,3 +436,4 @@ });

model: config.model,
path: config.path
path: config.path,
tabName: config.tabName
})

@@ -431,3 +451,4 @@ });

model: config.model,
path: config.path
path: config.path,
tabName: config.tabName
})

@@ -444,3 +465,4 @@ });

model: config.model,
path: config.path
path: config.path,
tabName: config.tabName
})

@@ -490,3 +512,4 @@ });

model: config.model,
path: config.path
path: config.path,
tabName: config.tabName
})

@@ -640,3 +663,4 @@ });

model: config.model,
path: config.path
path: config.path,
tabName: config.tabName
})

@@ -653,3 +677,4 @@ });

model: config.model,
path: config.path
path: config.path,
tabName: config.tabName
})

@@ -662,6 +687,7 @@ });

for (const name in config.fields) {
addInterfacePropertyFromField({
addInterfacePropertyForField({
...config,
id: name.includes("-") ? `"${name}"` : name,
model: config.fields[name]
model: config.fields[name],
tabName: config.tabName
});

@@ -693,14 +719,18 @@ }

});
addInterfacePropertiesForFields({
fields,
interface: dataInterface,
sourceFile,
path: [
{
id: model.id,
model
}
],
fieldConfigs
});
for (const tabName in model.json) {
const { uid: _uidField, ...tabFields } = model.json[tabName];
addInterfacePropertiesForFields({
fields: tabFields,
interface: dataInterface,
sourceFile,
path: [
{
id: model.id,
model
}
],
fieldConfigs,
tabName
});
}
} else {

@@ -707,0 +737,0 @@ dataInterface = sourceFile.addTypeAlias({

{
"name": "prismic-ts-codegen",
"version": "0.0.3",
"version": "0.0.4",
"description": "An experimental Prismic model-to-TypeScript-type generator",

@@ -5,0 +5,0 @@ "keywords": [

@@ -29,5 +29,6 @@ import type {

fieldConfigs: FieldConfigs;
tabName?: string;
};
const addInterfacePropertyFromField = (
const addInterfacePropertyForField = (
config: AddInterfacePropertyFromFieldConfig,

@@ -49,2 +50,3 @@ ) => {

path: config.path,
tabName: config.tabName,
}),

@@ -64,2 +66,3 @@ });

path: config.path,
tabName: config.tabName,
}),

@@ -79,2 +82,3 @@ });

path: config.path,
tabName: config.tabName,
}),

@@ -112,2 +116,3 @@ });

path: config.path,
tabName: config.tabName,
}),

@@ -127,2 +132,3 @@ });

path: config.path,
tabName: config.tabName,
}),

@@ -147,2 +153,3 @@ });

path: config.path,
tabName: config.tabName,
}),

@@ -158,2 +165,3 @@ });

path: config.path,
tabName: config.tabName,
}),

@@ -181,2 +189,3 @@ });

path: config.path,
tabName: config.tabName,
}),

@@ -204,2 +213,3 @@ });

path: config.path,
tabName: config.tabName,
}),

@@ -219,2 +229,3 @@ });

path: config.path,
tabName: config.tabName,
}),

@@ -234,2 +245,3 @@ });

path: config.path,
tabName: config.tabName,
}),

@@ -251,2 +263,3 @@ });

path: config.path,
tabName: config.tabName,
}),

@@ -273,2 +286,3 @@ });

path: config.path,
tabName: config.tabName,
}),

@@ -284,2 +298,3 @@ });

path: config.path,
tabName: config.tabName,
}),

@@ -306,2 +321,3 @@ });

path: config.path,
tabName: config.tabName,
}),

@@ -317,2 +333,3 @@ });

path: config.path,
tabName: config.tabName,
}),

@@ -333,2 +350,3 @@ });

path: config.path,
tabName: config.tabName,
}),

@@ -348,2 +366,3 @@ });

path: config.path,
tabName: config.tabName,
}),

@@ -400,2 +419,3 @@ });

path: config.path,
tabName: config.tabName,
}),

@@ -581,2 +601,3 @@ });

path: config.path,
tabName: config.tabName,
}),

@@ -596,2 +617,3 @@ });

path: config.path,
tabName: config.tabName,
}),

@@ -608,2 +630,3 @@ });

fields: Record<string, AddInterfacePropertyFromFieldConfig["model"]>;
tabName?: string;
};

@@ -615,8 +638,9 @@

for (const name in config.fields) {
addInterfacePropertyFromField({
addInterfacePropertyForField({
...config,
id: name.includes("-") ? `"${name}"` : name,
model: config.fields[name],
tabName: config.tabName,
});
}
};

@@ -46,14 +46,22 @@ import type { CustomTypeModel, CustomTypeModelField } from "@prismicio/types";

});
addInterfacePropertiesForFields({
fields,
interface: dataInterface,
sourceFile: sourceFile,
path: [
{
id: model.id,
model: model,
},
],
fieldConfigs,
});
for (const tabName in model.json) {
// This is destructured to ensure the UID field is
// ignored.
const { uid: _uidField, ...tabFields } = model.json[tabName];
addInterfacePropertiesForFields({
fields: tabFields,
interface: dataInterface,
sourceFile: sourceFile,
path: [
{
id: model.id,
model: model,
},
],
fieldConfigs,
tabName,
});
}
} else {

@@ -60,0 +68,0 @@ dataInterface = sourceFile.addTypeAlias({

@@ -24,2 +24,3 @@ import type {

];
tabName?: string;
};

@@ -67,2 +68,3 @@

apiIDPath,
tabName: config.tabName,
documentationURL: getFieldDocumentationURL({ model: config.model }),

@@ -69,0 +71,0 @@ });

@@ -10,2 +10,3 @@ import type { CodeBlockWriter } from "ts-morph";

apiIDPath?: string;
tabName?: string;
documentationURL?: string;

@@ -44,2 +45,6 @@ };

if (config.tabName) {
config.writer.writeLine(`- **Tab**: ${config.tabName}`);
}
if (config.documentationURL) {

@@ -46,0 +51,0 @@ config.writer.writeLine(`- **Documentation**: ${config.documentationURL}`);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet