From 2001b1e9a43b415a25e9e7726e94d351d1749e51 Mon Sep 17 00:00:00 2001 From: Remi Cattiau Date: Sun, 3 Dec 2023 15:46:50 -0800 Subject: [PATCH] fix: allow Binaries to define metadata and metadata schema --- packages/async/webda.module.json | 12 +- packages/core/src/core.spec.ts | 56 + packages/core/src/services/binary.ts | 2 +- packages/core/webda.module.json | 6 +- packages/gcp/webda.module.json | 173 +- packages/hawk/webda.module.json | 3 +- packages/postgres/webda.module.json | 2252 +++++++++++++++++++++- packages/shell/src/code/compiler.spec.ts | 40 +- packages/shell/src/code/compiler.ts | 84 +- sample-app/src/models/contact.ts | 2 +- sample-app/webda.module.json | 192 +- 11 files changed, 2610 insertions(+), 212 deletions(-) diff --git a/packages/async/webda.module.json b/packages/async/webda.module.json index 59645123e..2526350c9 100644 --- a/packages/async/webda.module.json +++ b/packages/async/webda.module.json @@ -198,16 +198,13 @@ "url": { "type": "string", "description": "URL to expose job status report hook", - "default": "/async/jobs" - }, - "store": { - "type": "string", - "description": "Store name to use for async actions", - "default": "AsyncActions" + "default": "/async/jobs", + "deprecated": "will be removed in 4.0 to only use object AsyncAction" }, "binaryStore": { "type": "string", - "description": "If we want to expose a way to upload/download binary for the job\n\nIt will expose a /download and /upload additional url" + "description": "If we want to expose a way to upload/download binary for the job\n\nIt will expose a /download and /upload additional url", + "deprecated": "will be removed in 4.0 to only use object AsyncAction" }, "localLaunch": { "type": "boolean", @@ -279,7 +276,6 @@ "logsLimit", "queue", "runners", - "store", "type", "url" ], diff --git a/packages/core/src/core.spec.ts b/packages/core/src/core.spec.ts index 2f152e577..96d211790 100644 --- a/packages/core/src/core.spec.ts +++ b/packages/core/src/core.spec.ts @@ -465,6 +465,62 @@ class CoreTest extends WebdaTest { assert.strictEqual(this.ctx.getParameters().provider, undefined); } + @test + validateSubSchema() { + const app = this.webda.getApplication(); + if (!app.hasSchema("obj1")) { + app.registerSchema("obj1", { + type: "object", + properties: { + uuid: { + type: "string" + }, + assets: { + $ref: "#/definitions/Binaries" + } + }, + definitions: { + Binaries: { + type: "object", + properties: { + upload: {} + }, + required: ["upload"], + description: "Define a collection of Binary with a Readonly and the upload method" + } + }, + required: ["uuid"] + }); + } + if (!app.hasSchema("obj2")) { + app.registerSchema("obj2", { + type: "object", + properties: { + uuid: { + type: "string" + }, + assets: { + $ref: "#/definitions/Binaries", + readOnly: true + } + }, + definitions: { + Binaries: { + type: "object", + properties: { + upload: {} + }, + required: ["upload"], + description: "Define a collection of Binary with a Readonly and the upload method" + } + }, + required: ["uuid"] + }); + } + this.webda.validateSchema("obj1", { uuid: "test" }); + this.webda.validateSchema("obj2", { uuid: "test2" }); + } + @test covValidateSchema() { assert.strictEqual(this.webda.validateSchema("test", {}), null); diff --git a/packages/core/src/services/binary.ts b/packages/core/src/services/binary.ts index 9eebdce7b..af54558ef 100644 --- a/packages/core/src/services/binary.ts +++ b/packages/core/src/services/binary.ts @@ -460,7 +460,7 @@ export class BinariesImpl extends Array> { /** * Define a collection of Binary with a Readonly and the upload method */ -export type Binaries = Readonly> & { upload: (file: BinaryFile) => Promise }; +export type Binaries = Readonly>> & { upload: (file: BinaryFile) => Promise }; export class BinaryParameters extends ServiceParameters { /** diff --git a/packages/core/webda.module.json b/packages/core/webda.module.json index f65cad590..5f8c0026f 100644 --- a/packages/core/webda.module.json +++ b/packages/core/webda.module.json @@ -1709,7 +1709,8 @@ "description": "UUID of the object" }, "_user": { - "type": "string" + "type": "string", + "readOnly": true }, "public": { "type": "boolean", @@ -2317,7 +2318,8 @@ "description": "UUID of the object" }, "_user": { - "type": "string" + "type": "string", + "readOnly": true }, "public": { "type": "boolean", diff --git a/packages/gcp/webda.module.json b/packages/gcp/webda.module.json index e5bc5c0c5..bfc524346 100644 --- a/packages/gcp/webda.module.json +++ b/packages/gcp/webda.module.json @@ -244,7 +244,7 @@ "retry": { "anyOf": [ { - "$ref": "#/definitions/Partial%3Cclass-1723313223-735-3044-1723313223-0-15050%3E" + "$ref": "#/definitions/Partial%3Cclass-657338214-735-3044-657338214-0-15050%3E" }, { "type": "null" @@ -637,7 +637,26 @@ "type": "number" }, { - "$ref": "#/definitions/Long" + "type": "object", + "properties": { + "high": { + "type": "number", + "description": "The high 32 bits as a signed value." + }, + "low": { + "type": "number", + "description": "The low 32 bits as a signed value." + }, + "unsigned": { + "type": "boolean", + "description": "Whether unsigned or not." + } + }, + "required": [ + "high", + "low", + "unsigned" + ] }, { "type": "string" @@ -670,7 +689,26 @@ "type": "number" }, { - "$ref": "#/definitions/Long" + "type": "object", + "properties": { + "high": { + "type": "number", + "description": "The high 32 bits as a signed value." + }, + "low": { + "type": "number", + "description": "The low 32 bits as a signed value." + }, + "unsigned": { + "type": "boolean", + "description": "Whether unsigned or not." + } + }, + "required": [ + "high", + "low", + "unsigned" + ] }, { "type": "string" @@ -768,7 +806,26 @@ "type": "number" }, { - "$ref": "#/definitions/Long" + "type": "object", + "properties": { + "high": { + "type": "number", + "description": "The high 32 bits as a signed value." + }, + "low": { + "type": "number", + "description": "The low 32 bits as a signed value." + }, + "unsigned": { + "type": "boolean", + "description": "Whether unsigned or not." + } + }, + "required": [ + "high", + "low", + "unsigned" + ] }, { "type": "string" @@ -855,7 +912,26 @@ "type": "number" }, { - "$ref": "#/definitions/Long" + "type": "object", + "properties": { + "high": { + "type": "number", + "description": "The high 32 bits as a signed value." + }, + "low": { + "type": "number", + "description": "The low 32 bits as a signed value." + }, + "unsigned": { + "type": "boolean", + "description": "Whether unsigned or not." + } + }, + "required": [ + "high", + "low", + "unsigned" + ] }, { "type": "string" @@ -893,7 +969,26 @@ "type": "number" }, { - "$ref": "#/definitions/Long" + "type": "object", + "properties": { + "high": { + "type": "number", + "description": "The high 32 bits as a signed value." + }, + "low": { + "type": "number", + "description": "The low 32 bits as a signed value." + }, + "unsigned": { + "type": "boolean", + "description": "Whether unsigned or not." + } + }, + "required": [ + "high", + "low", + "unsigned" + ] }, { "type": "string" @@ -954,7 +1049,26 @@ "type": "number" }, { - "$ref": "#/definitions/Long" + "type": "object", + "properties": { + "high": { + "type": "number", + "description": "The high 32 bits as a signed value." + }, + "low": { + "type": "number", + "description": "The low 32 bits as a signed value." + }, + "unsigned": { + "type": "boolean", + "description": "Whether unsigned or not." + } + }, + "required": [ + "high", + "low", + "unsigned" + ] }, { "type": "string" @@ -1015,7 +1129,26 @@ "type": "number" }, { - "$ref": "#/definitions/Long" + "type": "object", + "properties": { + "high": { + "type": "number", + "description": "The high 32 bits as a signed value." + }, + "low": { + "type": "number", + "description": "The low 32 bits as a signed value." + }, + "unsigned": { + "type": "boolean", + "description": "Whether unsigned or not." + } + }, + "required": [ + "high", + "low", + "unsigned" + ] }, { "type": "string" @@ -1049,7 +1182,7 @@ } } }, - "Partial": { + "Partial": { "type": "object", "properties": { "retryCodes": { @@ -1117,28 +1250,6 @@ ], "description": "State enum." }, - "Long": { - "type": "object", - "properties": { - "high": { - "type": "number", - "description": "The high 32 bits as a signed value." - }, - "low": { - "type": "number", - "description": "The low 32 bits as a signed value." - }, - "unsigned": { - "type": "boolean", - "description": "Whether unsigned or not." - } - }, - "required": [ - "high", - "low", - "unsigned" - ] - }, "google.pubsub.v1.CloudStorageConfig.State": { "type": "number", "enum": [ diff --git a/packages/hawk/webda.module.json b/packages/hawk/webda.module.json index 05c096b9d..d7d008a2d 100644 --- a/packages/hawk/webda.module.json +++ b/packages/hawk/webda.module.json @@ -72,7 +72,8 @@ "description": "UUID of the object" }, "_user": { - "type": "string" + "type": "string", + "readOnly": true }, "public": { "type": "boolean", diff --git a/packages/postgres/webda.module.json b/packages/postgres/webda.module.json index e99b86c0a..049d8a631 100644 --- a/packages/postgres/webda.module.json +++ b/packages/postgres/webda.module.json @@ -131,6 +131,2213 @@ "default": false }, "postgresqlServer": { + "anyOf": [ + { + "type": "object", + "properties": { + "user": { + "type": "string" + }, + "database": { + "type": "string" + }, + "password": { + "anyOf": [ + { + "type": "string" + }, + {} + ] + }, + "port": { + "type": "number" + }, + "host": { + "type": "string" + }, + "connectionString": { + "type": "string" + }, + "keepAlive": { + "type": "boolean" + }, + "stream": { + "type": "object", + "properties": { + "writable": { + "type": "boolean", + "description": "Is `true` if it is safe to call `writable.write()`, which means the stream has not been destroyed, errored or ended." + }, + "writableEnded": { + "type": "boolean", + "description": "Is `true` after `writable.end()` has been called. This property does not indicate whether the data has been flushed, for this use `writable.writableFinished` instead." + }, + "writableFinished": { + "type": "boolean", + "description": "Is set to `true` immediately before the `'finish'` event is emitted." + }, + "writableHighWaterMark": { + "type": "number", + "description": "Return the value of `highWaterMark` passed when creating this `Writable`." + }, + "writableLength": { + "type": "number", + "description": "This property contains the number of bytes (or objects) in the queue ready to be written. The value provides introspection data regarding the status of the `highWaterMark`." + }, + "writableObjectMode": { + "type": "boolean", + "description": "Getter for the property `objectMode` of a given `Writable` stream." + }, + "writableCorked": { + "type": "number", + "description": "Number of times `writable.uncork()` needs to be called in order to fully uncork the stream." + }, + "destroyed": { + "type": "boolean", + "description": "Is `true` after `readable.destroy()` has been called." + }, + "closed": { + "type": "boolean", + "description": "Is true after 'close' has been emitted." + }, + "errored": { + "anyOf": [ + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "message": { + "type": "string" + }, + "stack": { + "type": "string" + } + }, + "required": [ + "name", + "message" + ] + }, + { + "type": "null" + } + ], + "description": "Returns error if the stream has been destroyed with an error." + }, + "writableNeedDrain": { + "type": "boolean", + "description": "Is `true` if the stream's buffer has been full and stream will emit 'drain'." + }, + "readable": { + "type": "boolean", + "description": "Is `true` if it is safe to call `readable.read()`, which means the stream has not been destroyed or emitted `'error'` or `'end'`." + }, + "readableAborted": { + "type": "boolean", + "description": "Returns whether the stream was destroyed or errored before emitting `'end'`." + }, + "readableDidRead": { + "type": "boolean", + "description": "Returns whether `'data'` has been emitted." + }, + "readableEncoding": { + "anyOf": [ + { + "$ref": "#/definitions/global.BufferEncoding" + }, + { + "type": "null" + } + ], + "description": "Getter for the property `encoding` of a given `Readable` stream. The `encoding`property can be set using the `readable.setEncoding()` method." + }, + "readableEnded": { + "type": "boolean", + "description": "Becomes `true` when `'end'` event is emitted." + }, + "readableFlowing": { + "type": [ + "boolean", + "null" + ], + "description": "This property reflects the current state of a `Readable` stream as described in the `Three states` section." + }, + "readableHighWaterMark": { + "type": "number", + "description": "Returns the value of `highWaterMark` passed when creating this `Readable`." + }, + "readableLength": { + "type": "number", + "description": "This property contains the number of bytes (or objects) in the queue ready to be read. The value provides introspection data regarding the status of the `highWaterMark`." + }, + "readableObjectMode": { + "type": "boolean", + "description": "Getter for the property `objectMode` of a given `Readable` stream." + }, + "allowHalfOpen": { + "type": "boolean", + "description": "If `false` then the stream will automatically end the writable side when the readable side ends. Set initially by the `allowHalfOpen` constructor option, which defaults to `false`.\n\nThis can be changed manually to change the half-open behavior of an existing`Duplex` stream instance, but must be changed before the `'end'` event is emitted." + } + }, + "required": [ + "allowHalfOpen", + "closed", + "destroyed", + "errored", + "readable", + "readableAborted", + "readableDidRead", + "readableEncoding", + "readableEnded", + "readableFlowing", + "readableHighWaterMark", + "readableLength", + "readableObjectMode", + "writable", + "writableCorked", + "writableEnded", + "writableFinished", + "writableHighWaterMark", + "writableLength", + "writableNeedDrain", + "writableObjectMode" + ], + "description": "Duplex streams are streams that implement both the `Readable` and `Writable` interfaces.\n\nExamples of `Duplex` streams include:\n\n* `TCP sockets`\n* `zlib streams`\n* `crypto streams`" + }, + "statement_timeout": { + "anyOf": [ + { + "type": "boolean", + "const": false + }, + { + "type": "number" + } + ] + }, + "parseInputDatesAsUTC": { + "type": "boolean" + }, + "ssl": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "object", + "properties": { + "secureContext": { + "type": "object", + "properties": { + "context": {} + }, + "required": [ + "context" + ], + "description": "An optional TLS context object from tls.createSecureContext()" + }, + "enableTrace": { + "type": "boolean", + "description": "When enabled, TLS packet trace information is written to `stderr`. This can be used to debug TLS connection problems.", + "default": false + }, + "requestCert": { + "type": "boolean", + "description": "If true the server will request a certificate from clients that connect and attempt to verify that certificate. Defaults to false." + }, + "ALPNProtocols": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "array", + "items": { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ], + "additionalProperties": { + "type": "number" + } + } + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ], + "additionalProperties": { + "type": "number" + } + } + ], + "description": "An array of strings or a Buffer naming possible ALPN protocols. (Protocols should be ordered by their priority.)" + }, + "SNICallback": { + "description": "SNICallback(servername, cb) A function that will be called if the client supports SNI TLS extension. Two arguments will be passed when called: servername and cb. SNICallback should invoke cb(null, ctx), where ctx is a SecureContext instance. (tls.createSecureContext(...) can be used to get a proper SecureContext.) If SNICallback wasn't provided the default callback with high-level API will be used (see below)." + }, + "rejectUnauthorized": { + "type": "boolean", + "description": "If true the server will reject any connection which is not authorized with the list of supplied CAs. This option only has an effect if requestCert is true.", + "default": true + }, + "ca": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + }, + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + } + ] + } + } + ], + "description": "Optionally override the trusted CA certificates. Default is to trust the well-known CAs curated by Mozilla. Mozilla's CAs are completely replaced when CAs are explicitly specified using this option." + }, + "cert": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + }, + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + } + ] + } + } + ], + "description": "Cert chains in PEM format. One cert chain should be provided per private key. Each cert chain should consist of the PEM formatted certificate for a provided private key, followed by the PEM formatted intermediate certificates (if any), in order, and not including the root CA (the root CA must be pre-known to the peer, see ca). When providing multiple cert chains, they do not have to be in the same order as their private keys in key. If the intermediate certificates are not provided, the peer will not be able to validate the certificate, and the handshake will fail." + }, + "sigalgs": { + "type": "string", + "description": "Colon-separated list of supported signature algorithms. The list can contain digest algorithms (SHA256, MD5 etc.), public key algorithms (RSA-PSS, ECDSA etc.), combination of both (e.g 'RSA+SHA384') or TLS v1.3 scheme names (e.g. rsa_pss_pss_sha512)." + }, + "ciphers": { + "type": "string", + "description": "Cipher suite specification, replacing the default. For more information, see modifying the default cipher suite. Permitted ciphers can be obtained via tls.getCiphers(). Cipher names must be uppercased in order for OpenSSL to accept them." + }, + "clientCertEngine": { + "type": "string", + "description": "Name of an OpenSSL engine which can provide the client certificate." + }, + "crl": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + }, + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + } + ] + } + } + ], + "description": "PEM formatted CRLs (Certificate Revocation Lists)." + }, + "dhparam": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + } + ], + "description": "Diffie Hellman parameters, required for Perfect Forward Secrecy. Use openssl dhparam to create the parameters. The key length must be greater than or equal to 1024 bits or else an error will be thrown. Although 1024 bits is permissible, use 2048 bits or larger for stronger security. If omitted or invalid, the parameters are silently discarded and DHE ciphers will not be available." + }, + "ecdhCurve": { + "type": "string", + "description": "A string describing a named curve or a colon separated list of curve NIDs or names, for example P-521:P-384:P-256, to use for ECDH key agreement. Set to auto to select the curve automatically. Use crypto.getCurves() to obtain a list of available curve names. On recent releases, openssl ecparam -list_curves will also display the name and description of each available elliptic curve. Default: tls.DEFAULT_ECDH_CURVE." + }, + "honorCipherOrder": { + "type": "boolean", + "description": "Attempt to use the server's cipher suite preferences instead of the client's. When true, causes SSL_OP_CIPHER_SERVER_PREFERENCE to be set in secureOptions" + }, + "key": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + }, + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + }, + { + "type": "object", + "properties": { + "pem": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + } + ], + "description": "Private keys in PEM format." + }, + "passphrase": { + "type": "string", + "description": "Optional passphrase." + } + }, + "required": [ + "pem" + ] + } + ] + } + } + ], + "description": "Private keys in PEM format. PEM allows the option of private keys being encrypted. Encrypted keys will be decrypted with options.passphrase. Multiple keys using different algorithms can be provided either as an array of unencrypted key strings or buffers, or an array of objects in the form {pem: [, passphrase: ]}. The object form can only occur in an array. object.passphrase is optional. Encrypted keys will be decrypted with object.passphrase if provided, or options.passphrase if it is not." + }, + "privateKeyEngine": { + "type": "string", + "description": "Name of an OpenSSL engine to get private key from. Should be used together with privateKeyIdentifier." + }, + "privateKeyIdentifier": { + "type": "string", + "description": "Identifier of a private key managed by an OpenSSL engine. Should be used together with privateKeyEngine. Should not be set together with key, because both options define a private key in different ways." + }, + "maxVersion": { + "$ref": "#/definitions/SecureVersion", + "description": "Optionally set the maximum TLS version to allow. One of `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified along with the `secureProtocol` option, use one or the other.\n**Default:** `'TLSv1.3'`, unless changed using CLI options. Using `--tls-max-v1.2` sets the default to `'TLSv1.2'`. Using `--tls-max-v1.3` sets the default to `'TLSv1.3'`. If multiple of the options are provided, the highest maximum is used." + }, + "minVersion": { + "$ref": "#/definitions/SecureVersion", + "description": "Optionally set the minimum TLS version to allow. One of `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified along with the `secureProtocol` option, use one or the other. It is not recommended to use less than TLSv1.2, but it may be required for interoperability.\n**Default:** `'TLSv1.2'`, unless changed using CLI options. Using `--tls-v1.0` sets the default to `'TLSv1'`. Using `--tls-v1.1` sets the default to `'TLSv1.1'`. Using `--tls-min-v1.3` sets the default to 'TLSv1.3'. If multiple of the options are provided, the lowest minimum is used." + }, + "passphrase": { + "type": "string", + "description": "Shared passphrase used for a single private key and/or a PFX." + }, + "pfx": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + }, + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + }, + { + "type": "object", + "properties": { + "buf": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + } + ], + "description": "PFX or PKCS12 encoded private key and certificate chain." + }, + "passphrase": { + "type": "string", + "description": "Optional passphrase." + } + }, + "required": [ + "buf" + ] + } + ] + } + } + ], + "description": "PFX or PKCS12 encoded private key and certificate chain. pfx is an alternative to providing key and cert individually. PFX is usually encrypted, if it is, passphrase will be used to decrypt it. Multiple PFX can be provided either as an array of unencrypted PFX buffers, or an array of objects in the form {buf: [, passphrase: ]}. The object form can only occur in an array. object.passphrase is optional. Encrypted PFX will be decrypted with object.passphrase if provided, or options.passphrase if it is not." + }, + "secureOptions": { + "type": "number", + "description": "Optionally affect the OpenSSL protocol behavior, which is not usually necessary. This should be used carefully if at all! Value is a numeric bitmask of the SSL_OP_* options from OpenSSL Options" + }, + "secureProtocol": { + "type": "string", + "description": "Legacy mechanism to select the TLS protocol version to use, it does not support independent control of the minimum and maximum version, and does not support limiting the protocol to TLSv1.3. Use minVersion and maxVersion instead. The possible values are listed as SSL_METHODS, use the function names as strings. For example, use 'TLSv1_1_method' to force TLS version 1.1, or 'TLS_method' to allow any TLS protocol version up to TLSv1.3. It is not recommended to use TLS versions less than 1.2, but it may be required for interoperability. Default: none, see minVersion." + }, + "sessionIdContext": { + "type": "string", + "description": "Opaque identifier used by servers to ensure session state is not shared between applications. Unused by clients." + }, + "ticketKeys": { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ], + "description": "48-bytes of cryptographically strong pseudo-random data. See Session Resumption for more information." + }, + "sessionTimeout": { + "type": "number", + "description": "The number of seconds after which a TLS session created by the server will no longer be resumable. See Session Resumption for more information. Default: 300." + }, + "host": { + "type": "string" + }, + "port": { + "type": "number" + }, + "path": { + "type": "string" + }, + "socket": { + "type": "object", + "properties": { + "writable": { + "type": "boolean", + "description": "Is `true` if it is safe to call `writable.write()`, which means the stream has not been destroyed, errored or ended." + }, + "writableEnded": { + "type": "boolean", + "description": "Is `true` after `writable.end()` has been called. This property does not indicate whether the data has been flushed, for this use `writable.writableFinished` instead." + }, + "writableFinished": { + "type": "boolean", + "description": "Is set to `true` immediately before the `'finish'` event is emitted." + }, + "writableHighWaterMark": { + "type": "number", + "description": "Return the value of `highWaterMark` passed when creating this `Writable`." + }, + "writableLength": { + "type": "number", + "description": "This property contains the number of bytes (or objects) in the queue ready to be written. The value provides introspection data regarding the status of the `highWaterMark`." + }, + "writableObjectMode": { + "type": "boolean", + "description": "Getter for the property `objectMode` of a given `Writable` stream." + }, + "writableCorked": { + "type": "number", + "description": "Number of times `writable.uncork()` needs to be called in order to fully uncork the stream." + }, + "destroyed": { + "type": "boolean", + "description": "Is `true` after `readable.destroy()` has been called." + }, + "closed": { + "type": "boolean", + "description": "Is true after 'close' has been emitted." + }, + "errored": { + "anyOf": [ + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "message": { + "type": "string" + }, + "stack": { + "type": "string" + } + }, + "required": [ + "name", + "message" + ] + }, + { + "type": "null" + } + ], + "description": "Returns error if the stream has been destroyed with an error." + }, + "writableNeedDrain": { + "type": "boolean", + "description": "Is `true` if the stream's buffer has been full and stream will emit 'drain'." + }, + "readable": { + "type": "boolean", + "description": "Is `true` if it is safe to call `readable.read()`, which means the stream has not been destroyed or emitted `'error'` or `'end'`." + }, + "readableAborted": { + "type": "boolean", + "description": "Returns whether the stream was destroyed or errored before emitting `'end'`." + }, + "readableDidRead": { + "type": "boolean", + "description": "Returns whether `'data'` has been emitted." + }, + "readableEncoding": { + "anyOf": [ + { + "$ref": "#/definitions/global.BufferEncoding" + }, + { + "type": "null" + } + ], + "description": "Getter for the property `encoding` of a given `Readable` stream. The `encoding`property can be set using the `readable.setEncoding()` method." + }, + "readableEnded": { + "type": "boolean", + "description": "Becomes `true` when `'end'` event is emitted." + }, + "readableFlowing": { + "type": [ + "boolean", + "null" + ], + "description": "This property reflects the current state of a `Readable` stream as described in the `Three states` section." + }, + "readableHighWaterMark": { + "type": "number", + "description": "Returns the value of `highWaterMark` passed when creating this `Readable`." + }, + "readableLength": { + "type": "number", + "description": "This property contains the number of bytes (or objects) in the queue ready to be read. The value provides introspection data regarding the status of the `highWaterMark`." + }, + "readableObjectMode": { + "type": "boolean", + "description": "Getter for the property `objectMode` of a given `Readable` stream." + }, + "allowHalfOpen": { + "type": "boolean", + "description": "If `false` then the stream will automatically end the writable side when the readable side ends. Set initially by the `allowHalfOpen` constructor option, which defaults to `false`.\n\nThis can be changed manually to change the half-open behavior of an existing`Duplex` stream instance, but must be changed before the `'end'` event is emitted." + } + }, + "required": [ + "allowHalfOpen", + "closed", + "destroyed", + "errored", + "readable", + "readableAborted", + "readableDidRead", + "readableEncoding", + "readableEnded", + "readableFlowing", + "readableHighWaterMark", + "readableLength", + "readableObjectMode", + "writable", + "writableCorked", + "writableEnded", + "writableFinished", + "writableHighWaterMark", + "writableLength", + "writableNeedDrain", + "writableObjectMode" + ], + "description": "Duplex streams are streams that implement both the `Readable` and `Writable` interfaces.\n\nExamples of `Duplex` streams include:\n\n* `TCP sockets`\n* `zlib streams`\n* `crypto streams`" + }, + "checkServerIdentity": { + "$comment": "(hostname: string, cert: PeerCertificate) -> Error | undefined" + }, + "servername": { + "type": "string" + }, + "session": { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + }, + "minDHSize": { + "type": "number" + }, + "lookup": { + "$ref": "#/definitions/LookupFunction" + }, + "timeout": { + "type": "number" + } + } + } + ] + }, + "query_timeout": { + "type": "number" + }, + "keepAliveInitialDelayMillis": { + "type": "number" + }, + "idle_in_transaction_session_timeout": { + "type": "number" + }, + "application_name": { + "type": "string" + }, + "connectionTimeoutMillis": { + "type": "number" + }, + "types": { + "type": "object", + "properties": { + "getTypeParser": {} + }, + "required": [ + "getTypeParser" + ] + } + } + }, + { + "type": "object", + "properties": { + "user": { + "type": "string" + }, + "database": { + "type": "string" + }, + "password": { + "anyOf": [ + { + "type": "string" + }, + {} + ] + }, + "port": { + "type": "number" + }, + "host": { + "type": "string" + }, + "connectionString": { + "type": "string" + }, + "keepAlive": { + "type": "boolean" + }, + "stream": { + "type": "object", + "properties": { + "writable": { + "type": "boolean", + "description": "Is `true` if it is safe to call `writable.write()`, which means the stream has not been destroyed, errored or ended." + }, + "writableEnded": { + "type": "boolean", + "description": "Is `true` after `writable.end()` has been called. This property does not indicate whether the data has been flushed, for this use `writable.writableFinished` instead." + }, + "writableFinished": { + "type": "boolean", + "description": "Is set to `true` immediately before the `'finish'` event is emitted." + }, + "writableHighWaterMark": { + "type": "number", + "description": "Return the value of `highWaterMark` passed when creating this `Writable`." + }, + "writableLength": { + "type": "number", + "description": "This property contains the number of bytes (or objects) in the queue ready to be written. The value provides introspection data regarding the status of the `highWaterMark`." + }, + "writableObjectMode": { + "type": "boolean", + "description": "Getter for the property `objectMode` of a given `Writable` stream." + }, + "writableCorked": { + "type": "number", + "description": "Number of times `writable.uncork()` needs to be called in order to fully uncork the stream." + }, + "destroyed": { + "type": "boolean", + "description": "Is `true` after `readable.destroy()` has been called." + }, + "closed": { + "type": "boolean", + "description": "Is true after 'close' has been emitted." + }, + "errored": { + "anyOf": [ + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "message": { + "type": "string" + }, + "stack": { + "type": "string" + } + }, + "required": [ + "name", + "message" + ] + }, + { + "type": "null" + } + ], + "description": "Returns error if the stream has been destroyed with an error." + }, + "writableNeedDrain": { + "type": "boolean", + "description": "Is `true` if the stream's buffer has been full and stream will emit 'drain'." + }, + "readable": { + "type": "boolean", + "description": "Is `true` if it is safe to call `readable.read()`, which means the stream has not been destroyed or emitted `'error'` or `'end'`." + }, + "readableAborted": { + "type": "boolean", + "description": "Returns whether the stream was destroyed or errored before emitting `'end'`." + }, + "readableDidRead": { + "type": "boolean", + "description": "Returns whether `'data'` has been emitted." + }, + "readableEncoding": { + "anyOf": [ + { + "$ref": "#/definitions/global.BufferEncoding" + }, + { + "type": "null" + } + ], + "description": "Getter for the property `encoding` of a given `Readable` stream. The `encoding`property can be set using the `readable.setEncoding()` method." + }, + "readableEnded": { + "type": "boolean", + "description": "Becomes `true` when `'end'` event is emitted." + }, + "readableFlowing": { + "type": [ + "boolean", + "null" + ], + "description": "This property reflects the current state of a `Readable` stream as described in the `Three states` section." + }, + "readableHighWaterMark": { + "type": "number", + "description": "Returns the value of `highWaterMark` passed when creating this `Readable`." + }, + "readableLength": { + "type": "number", + "description": "This property contains the number of bytes (or objects) in the queue ready to be read. The value provides introspection data regarding the status of the `highWaterMark`." + }, + "readableObjectMode": { + "type": "boolean", + "description": "Getter for the property `objectMode` of a given `Readable` stream." + }, + "allowHalfOpen": { + "type": "boolean", + "description": "If `false` then the stream will automatically end the writable side when the readable side ends. Set initially by the `allowHalfOpen` constructor option, which defaults to `false`.\n\nThis can be changed manually to change the half-open behavior of an existing`Duplex` stream instance, but must be changed before the `'end'` event is emitted." + } + }, + "required": [ + "allowHalfOpen", + "closed", + "destroyed", + "errored", + "readable", + "readableAborted", + "readableDidRead", + "readableEncoding", + "readableEnded", + "readableFlowing", + "readableHighWaterMark", + "readableLength", + "readableObjectMode", + "writable", + "writableCorked", + "writableEnded", + "writableFinished", + "writableHighWaterMark", + "writableLength", + "writableNeedDrain", + "writableObjectMode" + ], + "description": "Duplex streams are streams that implement both the `Readable` and `Writable` interfaces.\n\nExamples of `Duplex` streams include:\n\n* `TCP sockets`\n* `zlib streams`\n* `crypto streams`" + }, + "statement_timeout": { + "anyOf": [ + { + "type": "boolean", + "const": false + }, + { + "type": "number" + } + ] + }, + "parseInputDatesAsUTC": { + "type": "boolean" + }, + "ssl": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "object", + "properties": { + "secureContext": { + "type": "object", + "properties": { + "context": {} + }, + "required": [ + "context" + ], + "description": "An optional TLS context object from tls.createSecureContext()" + }, + "enableTrace": { + "type": "boolean", + "description": "When enabled, TLS packet trace information is written to `stderr`. This can be used to debug TLS connection problems.", + "default": false + }, + "requestCert": { + "type": "boolean", + "description": "If true the server will request a certificate from clients that connect and attempt to verify that certificate. Defaults to false." + }, + "ALPNProtocols": { + "anyOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "array", + "items": { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ], + "additionalProperties": { + "type": "number" + } + } + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ], + "additionalProperties": { + "type": "number" + } + } + ], + "description": "An array of strings or a Buffer naming possible ALPN protocols. (Protocols should be ordered by their priority.)" + }, + "SNICallback": { + "description": "SNICallback(servername, cb) A function that will be called if the client supports SNI TLS extension. Two arguments will be passed when called: servername and cb. SNICallback should invoke cb(null, ctx), where ctx is a SecureContext instance. (tls.createSecureContext(...) can be used to get a proper SecureContext.) If SNICallback wasn't provided the default callback with high-level API will be used (see below)." + }, + "rejectUnauthorized": { + "type": "boolean", + "description": "If true the server will reject any connection which is not authorized with the list of supplied CAs. This option only has an effect if requestCert is true.", + "default": true + }, + "ca": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + }, + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + } + ] + } + } + ], + "description": "Optionally override the trusted CA certificates. Default is to trust the well-known CAs curated by Mozilla. Mozilla's CAs are completely replaced when CAs are explicitly specified using this option." + }, + "cert": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + }, + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + } + ] + } + } + ], + "description": "Cert chains in PEM format. One cert chain should be provided per private key. Each cert chain should consist of the PEM formatted certificate for a provided private key, followed by the PEM formatted intermediate certificates (if any), in order, and not including the root CA (the root CA must be pre-known to the peer, see ca). When providing multiple cert chains, they do not have to be in the same order as their private keys in key. If the intermediate certificates are not provided, the peer will not be able to validate the certificate, and the handshake will fail." + }, + "sigalgs": { + "type": "string", + "description": "Colon-separated list of supported signature algorithms. The list can contain digest algorithms (SHA256, MD5 etc.), public key algorithms (RSA-PSS, ECDSA etc.), combination of both (e.g 'RSA+SHA384') or TLS v1.3 scheme names (e.g. rsa_pss_pss_sha512)." + }, + "ciphers": { + "type": "string", + "description": "Cipher suite specification, replacing the default. For more information, see modifying the default cipher suite. Permitted ciphers can be obtained via tls.getCiphers(). Cipher names must be uppercased in order for OpenSSL to accept them." + }, + "clientCertEngine": { + "type": "string", + "description": "Name of an OpenSSL engine which can provide the client certificate." + }, + "crl": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + }, + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + } + ] + } + } + ], + "description": "PEM formatted CRLs (Certificate Revocation Lists)." + }, + "dhparam": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + } + ], + "description": "Diffie Hellman parameters, required for Perfect Forward Secrecy. Use openssl dhparam to create the parameters. The key length must be greater than or equal to 1024 bits or else an error will be thrown. Although 1024 bits is permissible, use 2048 bits or larger for stronger security. If omitted or invalid, the parameters are silently discarded and DHE ciphers will not be available." + }, + "ecdhCurve": { + "type": "string", + "description": "A string describing a named curve or a colon separated list of curve NIDs or names, for example P-521:P-384:P-256, to use for ECDH key agreement. Set to auto to select the curve automatically. Use crypto.getCurves() to obtain a list of available curve names. On recent releases, openssl ecparam -list_curves will also display the name and description of each available elliptic curve. Default: tls.DEFAULT_ECDH_CURVE." + }, + "honorCipherOrder": { + "type": "boolean", + "description": "Attempt to use the server's cipher suite preferences instead of the client's. When true, causes SSL_OP_CIPHER_SERVER_PREFERENCE to be set in secureOptions" + }, + "key": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + }, + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + }, + { + "type": "object", + "properties": { + "pem": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + } + ], + "description": "Private keys in PEM format." + }, + "passphrase": { + "type": "string", + "description": "Optional passphrase." + } + }, + "required": [ + "pem" + ] + } + ] + } + } + ], + "description": "Private keys in PEM format. PEM allows the option of private keys being encrypted. Encrypted keys will be decrypted with options.passphrase. Multiple keys using different algorithms can be provided either as an array of unencrypted key strings or buffers, or an array of objects in the form {pem: [, passphrase: ]}. The object form can only occur in an array. object.passphrase is optional. Encrypted keys will be decrypted with object.passphrase if provided, or options.passphrase if it is not." + }, + "privateKeyEngine": { + "type": "string", + "description": "Name of an OpenSSL engine to get private key from. Should be used together with privateKeyIdentifier." + }, + "privateKeyIdentifier": { + "type": "string", + "description": "Identifier of a private key managed by an OpenSSL engine. Should be used together with privateKeyEngine. Should not be set together with key, because both options define a private key in different ways." + }, + "maxVersion": { + "$ref": "#/definitions/SecureVersion", + "description": "Optionally set the maximum TLS version to allow. One of `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified along with the `secureProtocol` option, use one or the other.\n**Default:** `'TLSv1.3'`, unless changed using CLI options. Using `--tls-max-v1.2` sets the default to `'TLSv1.2'`. Using `--tls-max-v1.3` sets the default to `'TLSv1.3'`. If multiple of the options are provided, the highest maximum is used." + }, + "minVersion": { + "$ref": "#/definitions/SecureVersion", + "description": "Optionally set the minimum TLS version to allow. One of `'TLSv1.3'`, `'TLSv1.2'`, `'TLSv1.1'`, or `'TLSv1'`. Cannot be specified along with the `secureProtocol` option, use one or the other. It is not recommended to use less than TLSv1.2, but it may be required for interoperability.\n**Default:** `'TLSv1.2'`, unless changed using CLI options. Using `--tls-v1.0` sets the default to `'TLSv1'`. Using `--tls-v1.1` sets the default to `'TLSv1.1'`. Using `--tls-min-v1.3` sets the default to 'TLSv1.3'. If multiple of the options are provided, the lowest minimum is used." + }, + "passphrase": { + "type": "string", + "description": "Shared passphrase used for a single private key and/or a PFX." + }, + "pfx": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + }, + { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + }, + { + "type": "object", + "properties": { + "buf": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + } + ], + "description": "PFX or PKCS12 encoded private key and certificate chain." + }, + "passphrase": { + "type": "string", + "description": "Optional passphrase." + } + }, + "required": [ + "buf" + ] + } + ] + } + } + ], + "description": "PFX or PKCS12 encoded private key and certificate chain. pfx is an alternative to providing key and cert individually. PFX is usually encrypted, if it is, passphrase will be used to decrypt it. Multiple PFX can be provided either as an array of unencrypted PFX buffers, or an array of objects in the form {buf: [, passphrase: ]}. The object form can only occur in an array. object.passphrase is optional. Encrypted PFX will be decrypted with object.passphrase if provided, or options.passphrase if it is not." + }, + "secureOptions": { + "type": "number", + "description": "Optionally affect the OpenSSL protocol behavior, which is not usually necessary. This should be used carefully if at all! Value is a numeric bitmask of the SSL_OP_* options from OpenSSL Options" + }, + "secureProtocol": { + "type": "string", + "description": "Legacy mechanism to select the TLS protocol version to use, it does not support independent control of the minimum and maximum version, and does not support limiting the protocol to TLSv1.3. Use minVersion and maxVersion instead. The possible values are listed as SSL_METHODS, use the function names as strings. For example, use 'TLSv1_1_method' to force TLS version 1.1, or 'TLS_method' to allow any TLS protocol version up to TLSv1.3. It is not recommended to use TLS versions less than 1.2, but it may be required for interoperability. Default: none, see minVersion." + }, + "sessionIdContext": { + "type": "string", + "description": "Opaque identifier used by servers to ensure session state is not shared between applications. Unused by clients." + }, + "ticketKeys": { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ], + "description": "48-bytes of cryptographically strong pseudo-random data. See Session Resumption for more information." + }, + "sessionTimeout": { + "type": "number", + "description": "The number of seconds after which a TLS session created by the server will no longer be resumable. See Session Resumption for more information. Default: 300." + }, + "host": { + "type": "string" + }, + "port": { + "type": "number" + }, + "path": { + "type": "string" + }, + "socket": { + "type": "object", + "properties": { + "writable": { + "type": "boolean", + "description": "Is `true` if it is safe to call `writable.write()`, which means the stream has not been destroyed, errored or ended." + }, + "writableEnded": { + "type": "boolean", + "description": "Is `true` after `writable.end()` has been called. This property does not indicate whether the data has been flushed, for this use `writable.writableFinished` instead." + }, + "writableFinished": { + "type": "boolean", + "description": "Is set to `true` immediately before the `'finish'` event is emitted." + }, + "writableHighWaterMark": { + "type": "number", + "description": "Return the value of `highWaterMark` passed when creating this `Writable`." + }, + "writableLength": { + "type": "number", + "description": "This property contains the number of bytes (or objects) in the queue ready to be written. The value provides introspection data regarding the status of the `highWaterMark`." + }, + "writableObjectMode": { + "type": "boolean", + "description": "Getter for the property `objectMode` of a given `Writable` stream." + }, + "writableCorked": { + "type": "number", + "description": "Number of times `writable.uncork()` needs to be called in order to fully uncork the stream." + }, + "destroyed": { + "type": "boolean", + "description": "Is `true` after `readable.destroy()` has been called." + }, + "closed": { + "type": "boolean", + "description": "Is true after 'close' has been emitted." + }, + "errored": { + "anyOf": [ + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "message": { + "type": "string" + }, + "stack": { + "type": "string" + } + }, + "required": [ + "name", + "message" + ] + }, + { + "type": "null" + } + ], + "description": "Returns error if the stream has been destroyed with an error." + }, + "writableNeedDrain": { + "type": "boolean", + "description": "Is `true` if the stream's buffer has been full and stream will emit 'drain'." + }, + "readable": { + "type": "boolean", + "description": "Is `true` if it is safe to call `readable.read()`, which means the stream has not been destroyed or emitted `'error'` or `'end'`." + }, + "readableAborted": { + "type": "boolean", + "description": "Returns whether the stream was destroyed or errored before emitting `'end'`." + }, + "readableDidRead": { + "type": "boolean", + "description": "Returns whether `'data'` has been emitted." + }, + "readableEncoding": { + "anyOf": [ + { + "$ref": "#/definitions/global.BufferEncoding" + }, + { + "type": "null" + } + ], + "description": "Getter for the property `encoding` of a given `Readable` stream. The `encoding`property can be set using the `readable.setEncoding()` method." + }, + "readableEnded": { + "type": "boolean", + "description": "Becomes `true` when `'end'` event is emitted." + }, + "readableFlowing": { + "type": [ + "boolean", + "null" + ], + "description": "This property reflects the current state of a `Readable` stream as described in the `Three states` section." + }, + "readableHighWaterMark": { + "type": "number", + "description": "Returns the value of `highWaterMark` passed when creating this `Readable`." + }, + "readableLength": { + "type": "number", + "description": "This property contains the number of bytes (or objects) in the queue ready to be read. The value provides introspection data regarding the status of the `highWaterMark`." + }, + "readableObjectMode": { + "type": "boolean", + "description": "Getter for the property `objectMode` of a given `Readable` stream." + }, + "allowHalfOpen": { + "type": "boolean", + "description": "If `false` then the stream will automatically end the writable side when the readable side ends. Set initially by the `allowHalfOpen` constructor option, which defaults to `false`.\n\nThis can be changed manually to change the half-open behavior of an existing`Duplex` stream instance, but must be changed before the `'end'` event is emitted." + } + }, + "required": [ + "allowHalfOpen", + "closed", + "destroyed", + "errored", + "readable", + "readableAborted", + "readableDidRead", + "readableEncoding", + "readableEnded", + "readableFlowing", + "readableHighWaterMark", + "readableLength", + "readableObjectMode", + "writable", + "writableCorked", + "writableEnded", + "writableFinished", + "writableHighWaterMark", + "writableLength", + "writableNeedDrain", + "writableObjectMode" + ], + "description": "Duplex streams are streams that implement both the `Readable` and `Writable` interfaces.\n\nExamples of `Duplex` streams include:\n\n* `TCP sockets`\n* `zlib streams`\n* `crypto streams`" + }, + "checkServerIdentity": { + "$comment": "(hostname: string, cert: PeerCertificate) -> Error | undefined" + }, + "servername": { + "type": "string" + }, + "session": { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "$ref": "#/definitions/ArrayBufferLike" + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ] + }, + "minDHSize": { + "type": "number" + }, + "lookup": { + "$ref": "#/definitions/LookupFunction" + }, + "timeout": { + "type": "number" + } + } + } + ] + }, + "query_timeout": { + "type": "number" + }, + "keepAliveInitialDelayMillis": { + "type": "number" + }, + "idle_in_transaction_session_timeout": { + "type": "number" + }, + "application_name": { + "type": "string" + }, + "connectionTimeoutMillis": { + "type": "number" + }, + "types": { + "type": "object", + "properties": { + "getTypeParser": {} + }, + "required": [ + "getTypeParser" + ] + }, + "max": { + "type": "number" + }, + "min": { + "type": "number" + }, + "idleTimeoutMillis": { + "type": "number" + }, + "log": {}, + "Promise": { + "$ref": "#/definitions/PromiseConstructorLike" + } + } + } + ], "description": "By default use environment variables" }, "autoCreateTable": { @@ -197,7 +2404,50 @@ } }, "deprecated": "Store should not be exposed directly anymore\nYou should use the DomainService instead" - } + }, + "global.BufferEncoding": { + "type": "string", + "enum": [ + "ascii", + "utf8", + "utf-8", + "utf16le", + "ucs2", + "ucs-2", + "base64", + "base64url", + "latin1", + "binary", + "hex" + ] + }, + "ArrayBufferLike": { + "anyOf": [ + { + "type": "object", + "properties": { + "byteLength": { + "type": "number" + } + }, + "required": [ + "byteLength" + ] + }, + {} + ] + }, + "SecureVersion": { + "type": "string", + "enum": [ + "TLSv1.3", + "TLSv1.2", + "TLSv1.1", + "TLSv1" + ] + }, + "LookupFunction": {}, + "PromiseConstructorLike": {} }, "title": "PostgresStore" } diff --git a/packages/shell/src/code/compiler.spec.ts b/packages/shell/src/code/compiler.spec.ts index c0c56cd34..838046aec 100644 --- a/packages/shell/src/code/compiler.spec.ts +++ b/packages/shell/src/code/compiler.spec.ts @@ -93,14 +93,50 @@ class CompilerTest { let compiler = new Compiler(app); compiler.compile(); let mod = compiler.generateModule(); + assert.deepStrictEqual(mod.schemas["WebdaDemo/Contact"].properties.avatar, { type: "object", readOnly: true }); + assert.deepStrictEqual(mod.schemas["WebdaDemo/Contact"].properties.photos, { + items: { + properties: { + location: { + properties: { + lat: { + type: "number" + }, + lng: { + type: "number" + } + }, + required: ["lat", "lng"], + type: "object" + } + }, + required: ["location"], + type: "object" + }, + readOnly: true, + type: "array" + }); + assert.deepStrictEqual(mod.schemas["WebdaDemo/User"].properties.profilePicture, { + type: "object", + properties: { width: { type: "number" }, height: { type: "number" } }, + required: ["width", "height"], + readOnly: true + }); + assert.deepStrictEqual(mod.schemas["WebdaDemo/User"].properties.images, { + type: "array", + items: { type: "object" }, + readOnly: true + }); + assert.strictEqual(mod.schemas["WebdaDemo/User"].properties.avatar, undefined); + assert.strictEqual(mod.schemas["WebdaDemo/User"].properties.photos, undefined); // Check schema have no properties that start with _ in required assert.deepStrictEqual( mod.schemas["WebdaDemo/SubProject"].required.filter(i => i.startsWith("_")), - ["_company"] + [] ); assert.deepStrictEqual( mod.schemas["WebdaDemo/Computer"].required.filter(i => i.startsWith("_")), - ["_user"] + [] ); } } diff --git a/packages/shell/src/code/compiler.ts b/packages/shell/src/code/compiler.ts index afe35915f..3e57c4764 100644 --- a/packages/shell/src/code/compiler.ts +++ b/packages/shell/src/code/compiler.ts @@ -272,7 +272,6 @@ class WebdaModelNodeParser extends InterfaceAndClassNodeParser { context: Context ): ObjectProperty[] | undefined { let hasRequiredNever = false; - const properties = (node.members as ts.NodeArray) .reduce( (members, member) => { @@ -306,37 +305,34 @@ class WebdaModelNodeParser extends InterfaceAndClassNodeParser { if (ignore) { return undefined; } - let optional = - jsDocs.filter(n => ["SchemaOptional", "readOnly"].includes(n.tagName.text)).length > 0 || - this.getPropertyName(member.name).startsWith("_"); + // @ts-ignore let typeName = member.type?.typeName?.escapedText; + let readOnly = + jsDocs.filter(n => n.tagName.text === "readOnly").length > 0 || + this.getPropertyName(member.name).startsWith("_"); + let optional = + readOnly || member.questionToken || jsDocs.find(n => "SchemaOptional" === n.tagName.text) !== undefined; + let type; + if (typeName === "ModelParent" || typeName === "ModelLink") { - return new ObjectProperty( - this.getPropertyName(member.name), - new StringType(), - !optional || typeName === "ModelParent" - ); + type = new StringType(); } else if (typeName === "ModelLinksSimpleArray") { - return new ObjectProperty(this.getPropertyName(member.name), new ArrayType(new StringType()), !optional); + type = new ArrayType(new StringType()); } else if (typeName === "ModelLinksArray") { - let type = ( + let subtype = ( this.childNodeParser.createType((member.type).typeArguments[1], context) ); - type.properties.push(new ObjectProperty("uuid", new StringType(), true)); - return new ObjectProperty(this.getPropertyName(member.name), new ArrayType(type), !optional); + subtype.properties.push(new ObjectProperty("uuid", new StringType(), true)); + type = new ArrayType(subtype); } else if (typeName === "ModelLinksMap") { - let type = ( + let subtype = ( this.childNodeParser.createType((member.type).typeArguments[1], context) ); - type.properties.push(new ObjectProperty("uuid", new StringType(), true)); - return new ObjectProperty( - this.getPropertyName(member.name), - new ObjectType("modellinksmap-test", [], [], type), - !optional - ); + subtype.properties.push(new ObjectProperty("uuid", new StringType(), true)); + type = new ObjectType("modellinksmap-test", [], [], subtype); } else if (typeName === "ModelsMapped") { - let type = ( + let subtype = ( this.childNodeParser.createType((member.type).typeArguments[0], context) ); let attrs = this.childNodeParser.createType( @@ -354,34 +350,42 @@ class WebdaModelNodeParser extends InterfaceAndClassNodeParser { keep.push(t.getValue()); }); } - type.properties = type.properties.filter(o => keep.includes(o.name)); - type.properties.push(new ObjectProperty("uuid", new StringType(), true)); - return new ObjectProperty( - this.getPropertyName(member.name), - new ArrayType( - new ObjectType( - "modelmapped-test", - [], - type.properties.filter(o => !["get", "set", "toString"].includes(o.name)), - false - ) - ), - false + subtype.properties = subtype.properties.filter(o => keep.includes(o.name)); + subtype.properties.push(new ObjectProperty("uuid", new StringType(), true)); + type = new ArrayType( + new ObjectType( + "modelmapped-test", + [], + subtype.properties.filter(o => !["get", "set", "toString"].includes(o.name)), + false + ) ); + optional = true; + readOnly = true; } else if (typeName === "ModelRelated") { // ModelRelated are only helpers for backend development return undefined; } else if (typeName === "Binary" || typeName === "Binaries") { // Binary and Binaries should be readonly as they are only modifiable by a BinaryService optional = true; + readOnly = true; + if ((member.type).typeArguments?.length) { + type = this.childNodeParser.createType((member.type).typeArguments[0], context); + } else { + type = new ObjectType(typeName + "_" + this.getPropertyName(member.name), [], [], true); + //type["additionalProperties"] = true; + } + if (typeName !== "Binary") { + type = new ArrayType(type); + } + //return new ObjectProperty(this.getPropertyName(member.name), type, false); + } + type ??= this.childNodeParser.createType(member.type, context); + if (readOnly) { + type = new AnnotatedType(type, { readOnly: true }, false); } - let type = this.childNodeParser.createType(member.type, context); // If property is in readOnly then we do not want to require it - return new ObjectProperty( - this.getPropertyName(member.name), - type, - !member.questionToken && !optional && !this.getPropertyName(member.name).startsWith("_") - ); + return new ObjectProperty(this.getPropertyName(member.name), type, !optional); }) .filter(prop => { if (!prop) { diff --git a/sample-app/src/models/contact.ts b/sample-app/src/models/contact.ts index 9f07336d0..6cefff80f 100644 --- a/sample-app/src/models/contact.ts +++ b/sample-app/src/models/contact.ts @@ -52,7 +52,7 @@ export default class Contact extends CoreModel { /** * Contact photos */ - photos: Binaries; + photos: Binaries<{ location: { lat: number; lng: number } }>; /** * Contact owner diff --git a/sample-app/webda.module.json b/sample-app/webda.module.json index 6e0efcf69..203b5684f 100644 --- a/sample-app/webda.module.json +++ b/sample-app/webda.module.json @@ -430,7 +430,7 @@ "readonly": "number", "optional": "string", "avatar": "Binary", - "photos": "Binaries", + "photos": "Binaries<{ location: { lat: number; lng: number } }>", "owner": "ModelLink", "__class": "CoreModelDefinition", "__type": "string", @@ -736,7 +736,8 @@ "readOnly": true }, "_company": { - "type": "string" + "type": "string", + "readOnly": true }, "name": { "type": "string" @@ -749,7 +750,6 @@ } }, "required": [ - "_company", "name", "type", "uuid" @@ -889,7 +889,8 @@ "uuid" ], "additionalProperties": false - } + }, + "readOnly": true } }, "required": [ @@ -952,7 +953,8 @@ "uuid" ], "additionalProperties": false - } + }, + "readOnly": true }, "name": { "type": "string" @@ -996,17 +998,18 @@ "readOnly": true }, "_user": { - "type": "string" + "type": "string", + "readOnly": true }, "_loanTo": { - "type": "string" + "type": "string", + "readOnly": true }, "name": { "type": "string" } }, "required": [ - "_user", "name" ], "$schema": "http://json-schema.org/draft-07/schema#", @@ -1100,45 +1103,34 @@ }, "avatar": { "type": "object", - "properties": { - "hash": { - "type": "string", - "description": "Will be computed by the service\n\nhash of the content" - }, - "challenge": { - "type": "string", - "description": "Will be computed by the service\n\nhash of the content prefixed by 'WEBDA'" - }, - "size": { - "type": "number", - "description": "Size of the binary" - }, - "name": { - "type": "string", - "description": "Current name" - }, - "mimetype": { - "type": "string", - "description": "Mimetype of the binary" - }, - "metadata": { - "description": "Metadatas stored along with the binary" - }, - "originalname": { - "type": "string", - "description": "Original name" - } - }, - "required": [ - "mimetype", - "name", - "size" - ], - "description": "Contact avatar" + "readOnly": true }, "photos": { - "$ref": "#/definitions/Binaries", - "description": "Contact photos" + "type": "array", + "items": { + "type": "object", + "properties": { + "location": { + "type": "object", + "properties": { + "lat": { + "type": "number" + }, + "lng": { + "type": "number" + } + }, + "required": [ + "lat", + "lng" + ] + } + }, + "required": [ + "location" + ] + }, + "readOnly": true }, "owner": { "type": "string" @@ -1152,18 +1144,6 @@ "owner" ], "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "Binaries": { - "type": "object", - "properties": { - "upload": {} - }, - "required": [ - "upload" - ], - "description": "Define a collection of Binary with a Readonly and the upload method" - } - }, "title": "Contact" }, "WebdaDemo/Course": { @@ -1423,7 +1403,8 @@ "readOnly": true }, "_company": { - "type": "string" + "type": "string", + "readOnly": true }, "name": { "type": "string" @@ -1436,7 +1417,6 @@ } }, "required": [ - "_company", "name", "type", "uuid" @@ -1668,7 +1648,8 @@ "uuid" ], "additionalProperties": false - } + }, + "readOnly": true }, "constraints": { "type": "null" @@ -1707,7 +1688,8 @@ "readOnly": true }, "_company": { - "type": "string" + "type": "string", + "readOnly": true }, "name": { "type": "string" @@ -1720,7 +1702,6 @@ } }, "required": [ - "_company", "name", "type", "uuid" @@ -1749,7 +1730,8 @@ "readOnly": true }, "_company": { - "type": "string" + "type": "string", + "readOnly": true }, "name": { "type": "string" @@ -1765,7 +1747,6 @@ } }, "required": [ - "_company", "attribute1", "name", "type", @@ -1792,7 +1773,8 @@ "type": "object", "properties": { "_company": { - "type": "string" + "type": "string", + "readOnly": true }, "name": { "type": "string" @@ -1851,7 +1833,8 @@ "uuid" ], "additionalProperties": false - } + }, + "readOnly": true }, "students": { "type": "array", @@ -1878,7 +1861,8 @@ "uuid" ], "additionalProperties": false - } + }, + "readOnly": true }, "name": { "type": "string" @@ -1991,7 +1975,8 @@ "description": "Contain main user email if exists" }, "_company": { - "type": "string" + "type": "string", + "readOnly": true }, "name": { "type": "string" @@ -1999,56 +1984,25 @@ "profilePicture": { "type": "object", "properties": { - "hash": { - "type": "string", - "description": "Will be computed by the service\n\nhash of the content" - }, - "challenge": { - "type": "string", - "description": "Will be computed by the service\n\nhash of the content prefixed by 'WEBDA'" + "width": { + "type": "number" }, - "size": { - "type": "number", - "description": "Size of the binary" - }, - "name": { - "type": "string", - "description": "Current name" - }, - "mimetype": { - "type": "string", - "description": "Mimetype of the binary" - }, - "metadata": { - "type": "object", - "properties": { - "width": { - "type": "number" - }, - "height": { - "type": "number" - } - }, - "required": [ - "width", - "height" - ], - "description": "Metadatas stored along with the binary" - }, - "originalname": { - "type": "string", - "description": "Original name" + "height": { + "type": "number" } }, "required": [ - "mimetype", - "name", - "size" + "width", + "height" ], - "description": "One Binary instance" + "readOnly": true }, "images": { - "$ref": "#/definitions/Binaries" + "type": "array", + "items": { + "type": "object" + }, + "readOnly": true }, "contacts": { "type": "array", @@ -2079,27 +2033,15 @@ "uuid" ], "additionalProperties": false - } + }, + "readOnly": true } }, "required": [ - "_company", "displayName", "name" ], "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "Binaries": { - "type": "object", - "properties": { - "upload": {} - }, - "required": [ - "upload" - ], - "description": "Define a collection of Binary with a Readonly and the upload method" - } - }, "title": "User" } }