@stately-cloud/schema
Advanced tools
Comparing version 0.11.0 to 0.12.0
@@ -14,3 +14,3 @@ // Copyright 2023 Buf Technologies, Inc. | ||
// limitations under the License. | ||
// @generated by protoc-gen-es v2.1.0 with parameter "target=js+dts,import_extension=.js" | ||
// @generated by protoc-gen-es v2.2.2 with parameter "target=js+dts,import_extension=.js" | ||
// @generated from file buf/validate/expression.proto (package buf.validate, syntax proto3) | ||
@@ -17,0 +17,0 @@ /* eslint-disable */ |
@@ -14,3 +14,3 @@ // Copyright 2023 Buf Technologies, Inc. | ||
// limitations under the License. | ||
// @generated by protoc-gen-es v2.1.0 with parameter "target=js+dts,import_extension=.js" | ||
// @generated by protoc-gen-es v2.2.2 with parameter "target=js+dts,import_extension=.js" | ||
// @generated from file buf/validate/priv/private.proto (package buf.validate.priv, syntax proto3) | ||
@@ -17,0 +17,0 @@ /* eslint-disable */ |
@@ -0,1 +1,2 @@ | ||
export declare const getPackageName: () => string; | ||
/** | ||
@@ -2,0 +3,0 @@ * The build function is used by the CLI to build a binary DSLResponse file from |
@@ -12,2 +12,4 @@ import { create, toBinary } from "@bufbuild/protobuf"; | ||
import { DSLResponseSchema } from "./schemaservice/cli_pb.js"; | ||
// getPackageName returns the package name to use for the schema. | ||
export const getPackageName = () => process.env.PACKAGE || "stately.generated"; | ||
/** | ||
@@ -27,2 +29,12 @@ * The build function is used by the CLI to build a binary DSLResponse file from | ||
const fullInputPath = path.resolve(inputPath); | ||
// We need to be able to generate unique package names for each schema file so that | ||
// types do not collide in proto registries. (e.g. My app uses two different unrelated | ||
// schemas, cpschema, and testschema). To do this we will add the file name to the package | ||
// we generate. However, the program we create below to parse the input schema | ||
// essentially runs a disconnected version of the DSL i.e. variables cannot be shared | ||
// between the current runtime and the program we create below. Thus, when types are | ||
// registered they will be registered with a default package name unless we have a way | ||
// to communicate the package name to the program. Since we are still running in the same | ||
// process, we can use an environment variable to do this. | ||
process.env.PACKAGE = fileName ? `stately.generated.${fileName}` : "stately.generated"; | ||
process.stderr.write(`Building schema from ${fullInputPath}`); | ||
@@ -89,3 +101,3 @@ // Use TypeScript to parse the input files. | ||
try { | ||
fd = file(schemaTypes, fileName); | ||
fd = file(schemaTypes, fileName, getPackageName()); | ||
} | ||
@@ -92,0 +104,0 @@ catch (e) { |
@@ -1,2 +0,2 @@ | ||
// @generated by protoc-gen-es v2.1.0 with parameter "target=js+dts,import_extension=.js" | ||
// @generated by protoc-gen-es v2.2.2 with parameter "target=js+dts,import_extension=.js" | ||
// @generated from file errors/error_details.proto (package stately.errors, syntax proto3) | ||
@@ -3,0 +3,0 @@ /* eslint-disable */ |
@@ -1,2 +0,2 @@ | ||
// @generated by protoc-gen-es v2.1.0 with parameter "target=js+dts,import_extension=.js" | ||
// @generated by protoc-gen-es v2.2.2 with parameter "target=js+dts,import_extension=.js" | ||
// @generated from file extensions.proto (package stately.schemamodel, syntax proto3) | ||
@@ -3,0 +3,0 @@ /* eslint-disable */ |
@@ -5,2 +5,3 @@ import { create, isMessage, setExtension } from "@bufbuild/protobuf"; | ||
import { FieldConstraintsSchema, field as bufField } from "./buf/validate/validate_pb.js"; | ||
import { getPackageName } from "./driver.js"; | ||
import { field as statelyField } from "./extensions_pb.js"; | ||
@@ -62,3 +63,3 @@ import { BytesInterpretAs, BytesOptionsSchema, DoubleOptionsSchema, FieldOptions_FromMetadata, FieldOptions_InitialValue, Fixed32OptionsSchema, Fixed64OptionsSchema, FloatOptionsSchema, Int32OptionsSchema, Int64OptionsSchema, NumberInterpretAs, SFixed32OptionsSchema, SInt32OptionsSchema, SInt64OptionsSchema, FieldOptionsSchema as StatelyFieldOptionsSchema, StringInterpretAs, StringOptionsSchema, UInt32OptionsSchema, UInt64OptionsSchema, } from "./options_pb.js"; | ||
// https://groups.google.com/g/protobuf/c/AM2tSnfwfqU/m/Fj234vSiDgAJ | ||
field.typeName = `.stately.generated.${typeInfo.underlyingType.name}`; | ||
field.typeName = `.${getPackageName()}.${typeInfo.underlyingType.name}`; | ||
field.type = isMessage(typeInfo.underlyingType, EnumDescriptorProtoSchema) | ||
@@ -65,0 +66,0 @@ ? FieldDescriptorProto_Type.ENUM |
import { FileDescriptorProto } from "@bufbuild/protobuf/wkt"; | ||
import { Deferred, Plural } from "./type-util.js"; | ||
import { SchemaType } from "./types.js"; | ||
export declare function file(schemaTypes: Deferred<Plural<SchemaType>>[], fileName: string): FileDescriptorProto; | ||
export declare function file(schemaTypes: Deferred<Plural<SchemaType>>[], fileName: string, packageName: string): FileDescriptorProto; |
@@ -6,4 +6,3 @@ import { create } from "@bufbuild/protobuf"; | ||
import { resolveType } from "./types.js"; | ||
const packageName = "stately.generated"; | ||
export function file(schemaTypes, fileName) { | ||
export function file(schemaTypes, fileName, packageName) { | ||
const fd = create(FileDescriptorProtoSchema, { | ||
@@ -10,0 +9,0 @@ name: `${fileName || "stately"}.proto`, // TODO: for now, we pretend everything was in a single "file" |
import { create } from "@bufbuild/protobuf"; | ||
import { getPackageName } from "./driver.js"; | ||
import { MigrateActionSchema, MigrationCommandSchema, MigrationSchema, } from "./migration_pb.js"; | ||
@@ -13,3 +14,3 @@ /** | ||
// TODO: this hardcoded package name is gonna bite us someday | ||
const typeName = `stately.generated.${name}`; | ||
const typeName = `${getPackageName()}.${name}`; | ||
this.command = create(MigrationCommandSchema, { | ||
@@ -117,3 +118,3 @@ typeName, | ||
this.migration.commands.push(create(MigrationCommandSchema, { | ||
typeName: `stately.generated.${name}`, | ||
typeName: `${getPackageName()}.${name}`, | ||
actions: [ | ||
@@ -136,3 +137,3 @@ { | ||
this.migration.commands.push(create(MigrationCommandSchema, { | ||
typeName: `stately.generated.${oldName}`, | ||
typeName: `${getPackageName()}.${oldName}`, | ||
actions: [ | ||
@@ -143,3 +144,3 @@ { | ||
value: { | ||
newName: `stately.generated.${newName}`, | ||
newName: `${getPackageName()}.${newName}`, | ||
}, | ||
@@ -146,0 +147,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
// @generated by protoc-gen-es v2.1.0 with parameter "target=js+dts,import_extension=.js" | ||
// @generated by protoc-gen-es v2.2.2 with parameter "target=js+dts,import_extension=.js" | ||
// @generated from file migration.proto (package stately.schemamodel, syntax proto3) | ||
@@ -3,0 +3,0 @@ /* eslint-disable */ |
@@ -1,2 +0,2 @@ | ||
// @generated by protoc-gen-es v2.1.0 with parameter "target=js+dts,import_extension=.js" | ||
// @generated by protoc-gen-es v2.2.2 with parameter "target=js+dts,import_extension=.js" | ||
// @generated from file options.proto (package stately.schemamodel, syntax proto3) | ||
@@ -3,0 +3,0 @@ /* eslint-disable */ |
@@ -1,2 +0,2 @@ | ||
// @generated by protoc-gen-es v2.1.0 with parameter "target=js+dts,import_extension=.js" | ||
// @generated by protoc-gen-es v2.2.2 with parameter "target=js+dts,import_extension=.js" | ||
// @generated from file schemaservice/cli.proto (package stately.schemaservice, syntax proto3) | ||
@@ -3,0 +3,0 @@ /* eslint-disable */ |
{ | ||
"name": "@stately-cloud/schema", | ||
"version": "0.11.0", | ||
"version": "0.12.0", | ||
"author": "Stately Cloud <support@stately.cloud> (https://stately.cloud/)", | ||
@@ -5,0 +5,0 @@ "description": "Schema language for StatelyDB", |
Sorry, the diff of this file is too big to display
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
263239
3275
6