@devkong/cli 0.0.53 → 0.0.54

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.
Files changed (2) hide show
  1. package/index.js +49 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -75557,6 +75557,11 @@ var globalThisPolyfill = (function() {
75557
75557
  }
75558
75558
  })();
75559
75559
 
75560
+ // packages/kong-ts/src/lib/jq.ts
75561
+ function jqFilter(value) {
75562
+ return value;
75563
+ }
75564
+
75560
75565
  // packages/kong-ts/src/lib/jsonSchema.ts
75561
75566
  function createEmptyJsonSchema() {
75562
75567
  return {
@@ -85980,14 +85985,54 @@ var PublishVersionCommand = class {
85980
85985
  title: "Save publish details",
85981
85986
  task: async (ctx, task) => {
85982
85987
  const publishDetails = ctx.publishDetails;
85983
- const jsonSchemas = JSON.parse(ctx.contractText);
85988
+ let autoGeneratedContract;
85989
+ try {
85990
+ const parsed = JSON.parse(ctx.contractText);
85991
+ if (!parsed || typeof parsed !== "object") {
85992
+ throw new AppError(`Expected object got ${parsed}`);
85993
+ }
85994
+ autoGeneratedContract = {
85995
+ input: parsed.input,
85996
+ output: parsed.output
85997
+ };
85998
+ } catch (ex) {
85999
+ console.warn("failed to auto-generate contract", ex);
86000
+ autoGeneratedContract = {
86001
+ input: null,
86002
+ output: null
86003
+ };
86004
+ }
86005
+ const inputSchema = kongJson.settings?.input?.schema ?? autoGeneratedContract.input;
86006
+ const outputSchema = kongJson.settings?.output?.schema ?? autoGeneratedContract.output;
86007
+ const metadata = JSON.parse(JSON.stringify(kongJson));
86008
+ if (inputSchema || outputSchema) {
86009
+ if (!metadata.settings) {
86010
+ metadata.settings = {};
86011
+ }
86012
+ if (inputSchema) {
86013
+ metadata.settings.input = {
86014
+ ...metadata.settings.input || {
86015
+ filter: jqFilter("")
86016
+ },
86017
+ schema: inputSchema
86018
+ };
86019
+ }
86020
+ if (outputSchema) {
86021
+ metadata.settings.output = {
86022
+ ...metadata.settings.output || {
86023
+ filter: jqFilter("")
86024
+ },
86025
+ schema: outputSchema
86026
+ };
86027
+ }
86028
+ }
85984
86029
  const snapshot = {
85985
86030
  extensionId: kongJson.id,
85986
86031
  extensionName: kongJson.name,
85987
86032
  sdk: kongJson.sdk.toLowerCase(),
85988
- inputSchema: jsonSchemas.input,
85989
- outputSchema: jsonSchemas.output,
85990
- metadata: kongJson,
86033
+ inputSchema,
86034
+ outputSchema,
86035
+ metadata,
85991
86036
  version: Number(publishDetails.imageVersion),
85992
86037
  notes,
85993
86038
  checkpoint: "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devkong/cli",
3
- "version": "0.0.53",
3
+ "version": "0.0.54",
4
4
  "type": "commonjs",
5
5
  "main": "./index.js",
6
6
  "typings": "./index.d.ts",