@prisma/cli-init 0.6.1 → 0.6.2
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.
|
@@ -136717,20 +136717,6 @@ function _setPrototypeOf(o, p) {
|
|
|
136717
136717
|
};
|
|
136718
136718
|
return _setPrototypeOf(o, p);
|
|
136719
136719
|
}
|
|
136720
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
136721
|
-
if (source == null)
|
|
136722
|
-
return {};
|
|
136723
|
-
var target = {};
|
|
136724
|
-
var sourceKeys = Object.keys(source);
|
|
136725
|
-
var key, i;
|
|
136726
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
136727
|
-
key = sourceKeys[i];
|
|
136728
|
-
if (excluded.indexOf(key) >= 0)
|
|
136729
|
-
continue;
|
|
136730
|
-
target[key] = source[key];
|
|
136731
|
-
}
|
|
136732
|
-
return target;
|
|
136733
|
-
}
|
|
136734
136720
|
var Identifier = /* @__PURE__ */ createToken({
|
|
136735
136721
|
name: "Identifier",
|
|
136736
136722
|
pattern: /[a-zA-Z][\w-]*/
|
|
@@ -136894,17 +136880,6 @@ var multiModeTokens = {
|
|
|
136894
136880
|
defaultMode: "global"
|
|
136895
136881
|
};
|
|
136896
136882
|
var PrismaLexer = /* @__PURE__ */ new Lexer(multiModeTokens);
|
|
136897
|
-
var schemaObjects = ["model", "view", "type"];
|
|
136898
|
-
function isOneOfSchemaObjects(obj, schemas) {
|
|
136899
|
-
return obj != null && "type" in obj && schemas.includes(obj.type);
|
|
136900
|
-
}
|
|
136901
|
-
function isSchemaObject(obj) {
|
|
136902
|
-
return isOneOfSchemaObjects(obj, schemaObjects);
|
|
136903
|
-
}
|
|
136904
|
-
var fieldObjects = ["field", "enumerator"];
|
|
136905
|
-
function isSchemaField(field) {
|
|
136906
|
-
return field != null && "type" in field && fieldObjects.includes(field.type);
|
|
136907
|
-
}
|
|
136908
136883
|
function isToken(node) {
|
|
136909
136884
|
return "image" in node[0];
|
|
136910
136885
|
}
|
|
@@ -137867,451 +137842,6 @@ function computePropertyFormatting(list) {
|
|
|
137867
137842
|
return printProperty(prop, nameLengths[0], typeLengths[0]);
|
|
137868
137843
|
}).filter(Boolean).join(EOL + " ").replace(/(\r?\n\s*){3,}/g, EOL + EOL + " ");
|
|
137869
137844
|
}
|
|
137870
|
-
var findByType = function findByType2(list, typeToMatch, options) {
|
|
137871
|
-
if (options === void 0) {
|
|
137872
|
-
options = {};
|
|
137873
|
-
}
|
|
137874
|
-
var _list$filter = list.filter(findBy(typeToMatch, options)), match = _list$filter[0], unexpected = _list$filter[1];
|
|
137875
|
-
if (!match)
|
|
137876
|
-
return null;
|
|
137877
|
-
if (unexpected)
|
|
137878
|
-
throw new Error("Found multiple blocks with [type=" + typeToMatch + "]");
|
|
137879
|
-
return match;
|
|
137880
|
-
};
|
|
137881
|
-
var findAllByType = function findAllByType2(list, typeToMatch, options) {
|
|
137882
|
-
if (options === void 0) {
|
|
137883
|
-
options = {};
|
|
137884
|
-
}
|
|
137885
|
-
return list.filter(findBy(typeToMatch, options));
|
|
137886
|
-
};
|
|
137887
|
-
var findBy = function findBy2(typeToMatch, _temp) {
|
|
137888
|
-
var _ref = _temp === void 0 ? {} : _temp, name = _ref.name;
|
|
137889
|
-
return function(block) {
|
|
137890
|
-
if (name != null) {
|
|
137891
|
-
var nameAttribute = typeToMatch === "assignment" ? "key" : "name";
|
|
137892
|
-
if (!(nameAttribute in block))
|
|
137893
|
-
return false;
|
|
137894
|
-
var nameMatches = typeof name === "string" ? block[nameAttribute] === name : name.test(block[nameAttribute]);
|
|
137895
|
-
if (!nameMatches)
|
|
137896
|
-
return false;
|
|
137897
|
-
}
|
|
137898
|
-
return block.type === typeToMatch;
|
|
137899
|
-
};
|
|
137900
|
-
};
|
|
137901
|
-
var _excluded = ["within"];
|
|
137902
|
-
var _excluded2 = ["within"];
|
|
137903
|
-
var ConcretePrismaSchemaBuilder = /* @__PURE__ */ function() {
|
|
137904
|
-
function ConcretePrismaSchemaBuilder2(source) {
|
|
137905
|
-
if (source === void 0) {
|
|
137906
|
-
source = "";
|
|
137907
|
-
}
|
|
137908
|
-
this.schema = void 0;
|
|
137909
|
-
this._subject = void 0;
|
|
137910
|
-
this._parent = void 0;
|
|
137911
|
-
this.schema = getSchema(source);
|
|
137912
|
-
}
|
|
137913
|
-
var _proto = ConcretePrismaSchemaBuilder2.prototype;
|
|
137914
|
-
_proto.print = function print(options) {
|
|
137915
|
-
if (options === void 0) {
|
|
137916
|
-
options = {};
|
|
137917
|
-
}
|
|
137918
|
-
return printSchema(this.schema, options);
|
|
137919
|
-
};
|
|
137920
|
-
_proto.getSchema = function getSchema2() {
|
|
137921
|
-
return this.schema;
|
|
137922
|
-
};
|
|
137923
|
-
_proto.generator = function generator(name, provider) {
|
|
137924
|
-
if (provider === void 0) {
|
|
137925
|
-
provider = "prisma-client-js";
|
|
137926
|
-
}
|
|
137927
|
-
var generator2 = this.schema.list.reduce(function(memo, block) {
|
|
137928
|
-
return block.type === "generator" && block.name === name ? block : memo;
|
|
137929
|
-
}, {
|
|
137930
|
-
type: "generator",
|
|
137931
|
-
name,
|
|
137932
|
-
assignments: [{
|
|
137933
|
-
type: "assignment",
|
|
137934
|
-
key: "provider",
|
|
137935
|
-
value: '"' + provider + '"'
|
|
137936
|
-
}]
|
|
137937
|
-
});
|
|
137938
|
-
if (!this.schema.list.includes(generator2))
|
|
137939
|
-
this.schema.list.push(generator2);
|
|
137940
|
-
this._subject = generator2;
|
|
137941
|
-
return this;
|
|
137942
|
-
};
|
|
137943
|
-
_proto.drop = function drop(name) {
|
|
137944
|
-
var index = this.schema.list.findIndex(function(block) {
|
|
137945
|
-
return "name" in block && block.name === name;
|
|
137946
|
-
});
|
|
137947
|
-
if (index !== -1)
|
|
137948
|
-
this.schema.list.splice(index, 1);
|
|
137949
|
-
return this;
|
|
137950
|
-
};
|
|
137951
|
-
_proto.datasource = function datasource(provider, url) {
|
|
137952
|
-
var datasource2 = {
|
|
137953
|
-
type: "datasource",
|
|
137954
|
-
name: "db",
|
|
137955
|
-
assignments: [{
|
|
137956
|
-
type: "assignment",
|
|
137957
|
-
key: "url",
|
|
137958
|
-
value: typeof url === "string" ? '"' + url + '"' : {
|
|
137959
|
-
type: "function",
|
|
137960
|
-
name: "env",
|
|
137961
|
-
params: ['"' + url.env + '"']
|
|
137962
|
-
}
|
|
137963
|
-
}, {
|
|
137964
|
-
type: "assignment",
|
|
137965
|
-
key: "provider",
|
|
137966
|
-
value: provider
|
|
137967
|
-
}]
|
|
137968
|
-
};
|
|
137969
|
-
var existingIndex = this.schema.list.findIndex(function(block) {
|
|
137970
|
-
return block.type === "datasource";
|
|
137971
|
-
});
|
|
137972
|
-
this.schema.list.splice(existingIndex, existingIndex !== -1 ? 1 : 0, datasource2);
|
|
137973
|
-
this._subject = datasource2;
|
|
137974
|
-
return this;
|
|
137975
|
-
};
|
|
137976
|
-
_proto.model = function model(name) {
|
|
137977
|
-
var model2 = this.schema.list.reduce(function(memo, block) {
|
|
137978
|
-
return block.type === "model" && block.name === name ? block : memo;
|
|
137979
|
-
}, {
|
|
137980
|
-
type: "model",
|
|
137981
|
-
name,
|
|
137982
|
-
properties: []
|
|
137983
|
-
});
|
|
137984
|
-
if (!this.schema.list.includes(model2))
|
|
137985
|
-
this.schema.list.push(model2);
|
|
137986
|
-
this._subject = model2;
|
|
137987
|
-
return this;
|
|
137988
|
-
};
|
|
137989
|
-
_proto.view = function view(name) {
|
|
137990
|
-
var view2 = this.schema.list.reduce(function(memo, block) {
|
|
137991
|
-
return block.type === "view" && block.name === name ? block : memo;
|
|
137992
|
-
}, {
|
|
137993
|
-
type: "view",
|
|
137994
|
-
name,
|
|
137995
|
-
properties: []
|
|
137996
|
-
});
|
|
137997
|
-
if (!this.schema.list.includes(view2))
|
|
137998
|
-
this.schema.list.push(view2);
|
|
137999
|
-
this._subject = view2;
|
|
138000
|
-
return this;
|
|
138001
|
-
};
|
|
138002
|
-
_proto.type = function type(name) {
|
|
138003
|
-
var type2 = this.schema.list.reduce(function(memo, block) {
|
|
138004
|
-
return block.type === "type" && block.name === name ? block : memo;
|
|
138005
|
-
}, {
|
|
138006
|
-
type: "type",
|
|
138007
|
-
name,
|
|
138008
|
-
properties: []
|
|
138009
|
-
});
|
|
138010
|
-
if (!this.schema.list.includes(type2))
|
|
138011
|
-
this.schema.list.push(type2);
|
|
138012
|
-
this._subject = type2;
|
|
138013
|
-
return this;
|
|
138014
|
-
};
|
|
138015
|
-
_proto["enum"] = function _enum(name, enumeratorNames) {
|
|
138016
|
-
if (enumeratorNames === void 0) {
|
|
138017
|
-
enumeratorNames = [];
|
|
138018
|
-
}
|
|
138019
|
-
var e = this.schema.list.reduce(function(memo, block) {
|
|
138020
|
-
return block.type === "enum" && block.name === name ? block : memo;
|
|
138021
|
-
}, {
|
|
138022
|
-
type: "enum",
|
|
138023
|
-
name,
|
|
138024
|
-
enumerators: enumeratorNames.map(function(name2) {
|
|
138025
|
-
return {
|
|
138026
|
-
type: "enumerator",
|
|
138027
|
-
name: name2
|
|
138028
|
-
};
|
|
138029
|
-
})
|
|
138030
|
-
});
|
|
138031
|
-
if (!this.schema.list.includes(e))
|
|
138032
|
-
this.schema.list.push(e);
|
|
138033
|
-
this._subject = e;
|
|
138034
|
-
return this;
|
|
138035
|
-
};
|
|
138036
|
-
_proto.enumerator = function enumerator(value) {
|
|
138037
|
-
var subject = this.getSubject();
|
|
138038
|
-
if (!subject || !("type" in subject) || subject.type !== "enum") {
|
|
138039
|
-
throw new Error("Subject must be a prisma enum!");
|
|
138040
|
-
}
|
|
138041
|
-
var enumerator2 = {
|
|
138042
|
-
type: "enumerator",
|
|
138043
|
-
name: value
|
|
138044
|
-
};
|
|
138045
|
-
subject.enumerators.push(enumerator2);
|
|
138046
|
-
this._parent = this._subject;
|
|
138047
|
-
this._subject = enumerator2;
|
|
138048
|
-
return this;
|
|
138049
|
-
};
|
|
138050
|
-
_proto.getSubject = function getSubject() {
|
|
138051
|
-
return this._subject;
|
|
138052
|
-
};
|
|
138053
|
-
_proto.getParent = function getParent() {
|
|
138054
|
-
return this._parent;
|
|
138055
|
-
};
|
|
138056
|
-
_proto.blockAttribute = function blockAttribute(name, args) {
|
|
138057
|
-
var subject = this.getSubject();
|
|
138058
|
-
if (subject.type !== "enum" && !isSchemaObject(subject)) {
|
|
138059
|
-
var parent = this.getParent();
|
|
138060
|
-
if (!isOneOfSchemaObjects(parent, ["model", "view", "type", "enum"]))
|
|
138061
|
-
throw new Error("Subject must be a prisma model, view, or type!");
|
|
138062
|
-
subject = this._subject = parent;
|
|
138063
|
-
}
|
|
138064
|
-
var attributeArgs = function() {
|
|
138065
|
-
if (!args)
|
|
138066
|
-
return [];
|
|
138067
|
-
if (typeof args === "string")
|
|
138068
|
-
return [{
|
|
138069
|
-
type: "attributeArgument",
|
|
138070
|
-
value: '"' + args + '"'
|
|
138071
|
-
}];
|
|
138072
|
-
if (Array.isArray(args))
|
|
138073
|
-
return [{
|
|
138074
|
-
type: "attributeArgument",
|
|
138075
|
-
value: {
|
|
138076
|
-
type: "array",
|
|
138077
|
-
args
|
|
138078
|
-
}
|
|
138079
|
-
}];
|
|
138080
|
-
return Object.entries(args).map(function(_ref) {
|
|
138081
|
-
var key = _ref[0], value = _ref[1];
|
|
138082
|
-
return {
|
|
138083
|
-
type: "attributeArgument",
|
|
138084
|
-
value: {
|
|
138085
|
-
type: "keyValue",
|
|
138086
|
-
key,
|
|
138087
|
-
value
|
|
138088
|
-
}
|
|
138089
|
-
};
|
|
138090
|
-
});
|
|
138091
|
-
}();
|
|
138092
|
-
var property = {
|
|
138093
|
-
type: "attribute",
|
|
138094
|
-
kind: "object",
|
|
138095
|
-
name,
|
|
138096
|
-
args: attributeArgs
|
|
138097
|
-
};
|
|
138098
|
-
if (subject.type === "enum") {
|
|
138099
|
-
subject.enumerators.push(property);
|
|
138100
|
-
} else {
|
|
138101
|
-
subject.properties.push(property);
|
|
138102
|
-
}
|
|
138103
|
-
return this;
|
|
138104
|
-
};
|
|
138105
|
-
_proto.attribute = function attribute(name, args) {
|
|
138106
|
-
var parent = this.getParent();
|
|
138107
|
-
var subject = this.getSubject();
|
|
138108
|
-
if (!isOneOfSchemaObjects(parent, ["model", "view", "type", "enum"])) {
|
|
138109
|
-
throw new Error("Parent must be a prisma model or view!");
|
|
138110
|
-
}
|
|
138111
|
-
if (!isSchemaField(subject)) {
|
|
138112
|
-
throw new Error("Subject must be a prisma field or enumerator!");
|
|
138113
|
-
}
|
|
138114
|
-
if (!subject.attributes)
|
|
138115
|
-
subject.attributes = [];
|
|
138116
|
-
var attribute2 = subject.attributes.reduce(function(memo, attr) {
|
|
138117
|
-
return attr.type === "attribute" && (attr.group ? attr.group + "." : "") + attr.name === name ? attr : memo;
|
|
138118
|
-
}, {
|
|
138119
|
-
type: "attribute",
|
|
138120
|
-
kind: "field",
|
|
138121
|
-
name
|
|
138122
|
-
});
|
|
138123
|
-
if (Array.isArray(args)) {
|
|
138124
|
-
var mapArg = function mapArg2(arg) {
|
|
138125
|
-
var _arg$function$map, _arg$function;
|
|
138126
|
-
return typeof arg === "string" ? arg : {
|
|
138127
|
-
type: "function",
|
|
138128
|
-
name: arg.name,
|
|
138129
|
-
params: (_arg$function$map = (_arg$function = arg["function"]) == null ? void 0 : _arg$function.map(mapArg2)) != null ? _arg$function$map : []
|
|
138130
|
-
};
|
|
138131
|
-
};
|
|
138132
|
-
if (args.length > 0)
|
|
138133
|
-
attribute2.args = args.map(function(arg) {
|
|
138134
|
-
return {
|
|
138135
|
-
type: "attributeArgument",
|
|
138136
|
-
value: mapArg(arg)
|
|
138137
|
-
};
|
|
138138
|
-
});
|
|
138139
|
-
} else if (typeof args === "object") {
|
|
138140
|
-
attribute2.args = Object.entries(args).map(function(_ref2) {
|
|
138141
|
-
var key = _ref2[0], value = _ref2[1];
|
|
138142
|
-
return {
|
|
138143
|
-
type: "attributeArgument",
|
|
138144
|
-
value: {
|
|
138145
|
-
type: "keyValue",
|
|
138146
|
-
key,
|
|
138147
|
-
value: {
|
|
138148
|
-
type: "array",
|
|
138149
|
-
args: value
|
|
138150
|
-
}
|
|
138151
|
-
}
|
|
138152
|
-
};
|
|
138153
|
-
});
|
|
138154
|
-
}
|
|
138155
|
-
if (!subject.attributes.includes(attribute2))
|
|
138156
|
-
subject.attributes.push(attribute2);
|
|
138157
|
-
return this;
|
|
138158
|
-
};
|
|
138159
|
-
_proto.removeAttribute = function removeAttribute(name) {
|
|
138160
|
-
var parent = this.getParent();
|
|
138161
|
-
var subject = this.getSubject();
|
|
138162
|
-
if (!isSchemaObject(parent)) {
|
|
138163
|
-
throw new Error("Parent must be a prisma model or view!");
|
|
138164
|
-
}
|
|
138165
|
-
if (!isSchemaField(subject)) {
|
|
138166
|
-
throw new Error("Subject must be a prisma field!");
|
|
138167
|
-
}
|
|
138168
|
-
if (!subject.attributes)
|
|
138169
|
-
subject.attributes = [];
|
|
138170
|
-
subject.attributes = subject.attributes.filter(function(attr) {
|
|
138171
|
-
return !(attr.type === "attribute" && attr.name === name);
|
|
138172
|
-
});
|
|
138173
|
-
return this;
|
|
138174
|
-
};
|
|
138175
|
-
_proto.assignment = function assignment(key, value) {
|
|
138176
|
-
var subject = this.getSubject();
|
|
138177
|
-
if (!subject || !("type" in subject) || !["generator", "datasource"].includes(subject.type))
|
|
138178
|
-
throw new Error("Subject must be a prisma generator or datasource!");
|
|
138179
|
-
function tap(subject2, callback) {
|
|
138180
|
-
callback(subject2);
|
|
138181
|
-
return subject2;
|
|
138182
|
-
}
|
|
138183
|
-
var assignment2 = subject.assignments.reduce(function(memo, assignment3) {
|
|
138184
|
-
return assignment3.type === "assignment" && assignment3.key === key ? tap(assignment3, function(a) {
|
|
138185
|
-
a.value = '"' + value + '"';
|
|
138186
|
-
}) : memo;
|
|
138187
|
-
}, {
|
|
138188
|
-
type: "assignment",
|
|
138189
|
-
key,
|
|
138190
|
-
value: '"' + value + '"'
|
|
138191
|
-
});
|
|
138192
|
-
if (!subject.assignments.includes(assignment2))
|
|
138193
|
-
subject.assignments.push(assignment2);
|
|
138194
|
-
return this;
|
|
138195
|
-
};
|
|
138196
|
-
_proto.findByType = function findByType$1(typeToMatch, _ref3) {
|
|
138197
|
-
var _ref3$within = _ref3.within, within = _ref3$within === void 0 ? this.schema.list : _ref3$within, options = _objectWithoutPropertiesLoose(_ref3, _excluded);
|
|
138198
|
-
return findByType(within, typeToMatch, options);
|
|
138199
|
-
};
|
|
138200
|
-
_proto.findAllByType = function findAllByType$1(typeToMatch, _ref4) {
|
|
138201
|
-
var _ref4$within = _ref4.within, within = _ref4$within === void 0 ? this.schema.list : _ref4$within, options = _objectWithoutPropertiesLoose(_ref4, _excluded2);
|
|
138202
|
-
return findAllByType(within, typeToMatch, options);
|
|
138203
|
-
};
|
|
138204
|
-
_proto.blockInsert = function blockInsert(statement) {
|
|
138205
|
-
var subject = this.getSubject();
|
|
138206
|
-
var allowed = ["datasource", "enum", "generator", "model", "view", "type"];
|
|
138207
|
-
if (!subject || !("type" in subject) || !allowed.includes(subject.type)) {
|
|
138208
|
-
var parent = this.getParent();
|
|
138209
|
-
if (!parent || !("type" in parent) || !allowed.includes(parent.type)) {
|
|
138210
|
-
throw new Error("Subject must be a prisma block!");
|
|
138211
|
-
}
|
|
138212
|
-
subject = this._subject = parent;
|
|
138213
|
-
}
|
|
138214
|
-
switch (subject.type) {
|
|
138215
|
-
case "datasource": {
|
|
138216
|
-
subject.assignments.push(statement);
|
|
138217
|
-
break;
|
|
138218
|
-
}
|
|
138219
|
-
case "enum": {
|
|
138220
|
-
subject.enumerators.push(statement);
|
|
138221
|
-
break;
|
|
138222
|
-
}
|
|
138223
|
-
case "generator": {
|
|
138224
|
-
subject.assignments.push(statement);
|
|
138225
|
-
break;
|
|
138226
|
-
}
|
|
138227
|
-
case "model": {
|
|
138228
|
-
subject.properties.push(statement);
|
|
138229
|
-
break;
|
|
138230
|
-
}
|
|
138231
|
-
}
|
|
138232
|
-
return this;
|
|
138233
|
-
};
|
|
138234
|
-
_proto["break"] = function _break() {
|
|
138235
|
-
var lineBreak = {
|
|
138236
|
-
type: "break"
|
|
138237
|
-
};
|
|
138238
|
-
return this.blockInsert(lineBreak);
|
|
138239
|
-
};
|
|
138240
|
-
_proto.comment = function comment(text, node) {
|
|
138241
|
-
if (node === void 0) {
|
|
138242
|
-
node = false;
|
|
138243
|
-
}
|
|
138244
|
-
var comment2 = {
|
|
138245
|
-
type: "comment",
|
|
138246
|
-
text: "//" + (node ? "/" : "") + " " + text
|
|
138247
|
-
};
|
|
138248
|
-
return this.blockInsert(comment2);
|
|
138249
|
-
};
|
|
138250
|
-
_proto.schemaComment = function schemaComment(text, node) {
|
|
138251
|
-
if (node === void 0) {
|
|
138252
|
-
node = false;
|
|
138253
|
-
}
|
|
138254
|
-
var comment = {
|
|
138255
|
-
type: "comment",
|
|
138256
|
-
text: "//" + (node ? "/" : "") + " " + text
|
|
138257
|
-
};
|
|
138258
|
-
this.schema.list.push(comment);
|
|
138259
|
-
return this;
|
|
138260
|
-
};
|
|
138261
|
-
_proto.field = function field(name, fieldType) {
|
|
138262
|
-
if (fieldType === void 0) {
|
|
138263
|
-
fieldType = "String";
|
|
138264
|
-
}
|
|
138265
|
-
var subject = this.getSubject();
|
|
138266
|
-
if (!isSchemaObject(subject)) {
|
|
138267
|
-
var parent = this.getParent();
|
|
138268
|
-
if (!isSchemaObject(parent))
|
|
138269
|
-
throw new Error("Subject must be a prisma model or view or composite type!");
|
|
138270
|
-
subject = this._subject = parent;
|
|
138271
|
-
}
|
|
138272
|
-
var field2 = subject.properties.reduce(function(memo, block) {
|
|
138273
|
-
return block.type === "field" && block.name === name ? block : memo;
|
|
138274
|
-
}, {
|
|
138275
|
-
type: "field",
|
|
138276
|
-
name,
|
|
138277
|
-
fieldType
|
|
138278
|
-
});
|
|
138279
|
-
if (!subject.properties.includes(field2))
|
|
138280
|
-
subject.properties.push(field2);
|
|
138281
|
-
this._parent = subject;
|
|
138282
|
-
this._subject = field2;
|
|
138283
|
-
return this;
|
|
138284
|
-
};
|
|
138285
|
-
_proto.removeField = function removeField(name) {
|
|
138286
|
-
var subject = this.getSubject();
|
|
138287
|
-
if (!isSchemaObject(subject)) {
|
|
138288
|
-
var parent = this.getParent();
|
|
138289
|
-
if (!isSchemaObject(parent))
|
|
138290
|
-
throw new Error("Subject must be a prisma model or view or composite type!");
|
|
138291
|
-
subject = this._subject = parent;
|
|
138292
|
-
}
|
|
138293
|
-
subject.properties = subject.properties.filter(function(field) {
|
|
138294
|
-
return !(field.type === "field" && field.name === name);
|
|
138295
|
-
});
|
|
138296
|
-
return this;
|
|
138297
|
-
};
|
|
138298
|
-
_proto.then = function then(callback) {
|
|
138299
|
-
callback(this._subject);
|
|
138300
|
-
return this;
|
|
138301
|
-
};
|
|
138302
|
-
return ConcretePrismaSchemaBuilder2;
|
|
138303
|
-
}();
|
|
138304
|
-
function createPrismaSchemaBuilder(source) {
|
|
138305
|
-
return new ConcretePrismaSchemaBuilder(source);
|
|
138306
|
-
}
|
|
138307
|
-
function produceSchema(source, producer, options) {
|
|
138308
|
-
if (options === void 0) {
|
|
138309
|
-
options = {};
|
|
138310
|
-
}
|
|
138311
|
-
var builder = createPrismaSchemaBuilder(source);
|
|
138312
|
-
producer(builder);
|
|
138313
|
-
return builder.print(options);
|
|
138314
|
-
}
|
|
138315
137845
|
|
|
138316
137846
|
// ../../dev/server/src/schema.ts
|
|
138317
137847
|
var SCHEMAS_BY_HASH = /* @__PURE__ */ new Map();
|
|
@@ -138332,10 +137862,21 @@ function assertSchema(ctx) {
|
|
|
138332
137862
|
return { schemaHash, schemas };
|
|
138333
137863
|
}
|
|
138334
137864
|
async function overrideDatasource(base64Schema, connectionString, debug) {
|
|
138335
|
-
const
|
|
138336
|
-
const
|
|
138337
|
-
|
|
138338
|
-
|
|
137865
|
+
const rawSchema = Buffer2.from(base64Schema, "base64").toString("utf8");
|
|
137866
|
+
const schema = getSchema(rawSchema);
|
|
137867
|
+
const datasourceNode = schema.list.find((item) => item.type === "datasource");
|
|
137868
|
+
if (!datasourceNode) {
|
|
137869
|
+
throw new Error("No datasource block found in schema.");
|
|
137870
|
+
}
|
|
137871
|
+
const urlAssignment = datasourceNode.assignments.find(
|
|
137872
|
+
(assignment) => assignment.type === "assignment" && assignment.key === "url"
|
|
137873
|
+
);
|
|
137874
|
+
if (!urlAssignment) {
|
|
137875
|
+
datasourceNode.assignments.push({ key: "url", type: "assignment", value: `"${connectionString.toString()}"` });
|
|
137876
|
+
} else {
|
|
137877
|
+
urlAssignment.value = `"${connectionString.toString()}"`;
|
|
137878
|
+
}
|
|
137879
|
+
const schemaWithOverride = printSchema(schema);
|
|
138339
137880
|
if (debug) {
|
|
138340
137881
|
console.log("[Accelerate] schema with override:", schemaWithOverride);
|
|
138341
137882
|
}
|
package/dist/index.js
CHANGED
|
@@ -2638,7 +2638,7 @@ async function getApp(port, dbServer, serverState) {
|
|
|
2638
2638
|
const { debug: debug3 } = serverState;
|
|
2639
2639
|
const [{ Hono }, { accelerateRoute }, { utilityRoute }] = await Promise.all([
|
|
2640
2640
|
import("hono/tiny"),
|
|
2641
|
-
import("./accelerate-
|
|
2641
|
+
import("./accelerate-7HJZB2GE.js"),
|
|
2642
2642
|
import("./utility-QJR3G2JJ.js")
|
|
2643
2643
|
]);
|
|
2644
2644
|
const app = new Hono();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/cli-init",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Init CLI for Prisma",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"tsup": "8.0.2",
|
|
37
37
|
"typescript": "5.8.3",
|
|
38
38
|
"vitest": "3.1.3",
|
|
39
|
-
"@prisma/dev": "0.
|
|
39
|
+
"@prisma/dev": "0.16.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@inquirer/prompts": "7.3.3",
|