From a2c947688444d663ca3b3f4341c3c4828109a0de Mon Sep 17 00:00:00 2001 From: vinckr Date: Wed, 2 Feb 2022 15:06:47 +0100 Subject: [PATCH 1/3] docs: correct npm SDK --- docs/docs/sdk.md | 2 +- docs/docs/self-service.mdx | 2 +- docs/versioned_docs/version-v0.8/sdk.md | 2 +- docs/versioned_docs/version-v0.8/self-service.mdx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/docs/sdk.md b/docs/docs/sdk.md index 0a23f00530cf..4c74e869ed44 100644 --- a/docs/docs/sdk.md +++ b/docs/docs/sdk.md @@ -22,7 +22,7 @@ repositories: - [.NET](https://www.nuget.org/packages/Ory.Kratos.Client/) - [Go](https://github.com/ory/kratos-client-go) - [Java](https://search.maven.org/artifact/sh.ory.kratos/kratos-client) -- [JavaScript](https://www.npmjs.com/package/@ory/kratos-client) with TypeScript +- [JavaScript](https://www.npmjs.com/package/@ory/client) with TypeScript definitions and compatible with: NodeJS, ReactJS, AngularJS, Vue.js, and many more. - [PHP](https://packagist.org/packages/ory/kratos-client) diff --git a/docs/docs/self-service.mdx b/docs/docs/self-service.mdx index 9cde90cee903..bfbe8408a316 100644 --- a/docs/docs/self-service.mdx +++ b/docs/docs/self-service.mdx @@ -639,7 +639,7 @@ snippet: ```tsx import React, { useState, useEffect } from 'react' import { Text, TextInput, View } from 'react-native' -import { Configuration, V0alpha2Api, LoginFlow } from '@ory/kratos-client' +import { Configuration, V0alpha2Api, LoginFlow } from '@ory/client' const kratos = new V0alpha2Api( new Configuration({ basePath: 'https://playground.projects.oryapis.com/api/kratos/public' }) diff --git a/docs/versioned_docs/version-v0.8/sdk.md b/docs/versioned_docs/version-v0.8/sdk.md index 0a23f00530cf..4c74e869ed44 100644 --- a/docs/versioned_docs/version-v0.8/sdk.md +++ b/docs/versioned_docs/version-v0.8/sdk.md @@ -22,7 +22,7 @@ repositories: - [.NET](https://www.nuget.org/packages/Ory.Kratos.Client/) - [Go](https://github.com/ory/kratos-client-go) - [Java](https://search.maven.org/artifact/sh.ory.kratos/kratos-client) -- [JavaScript](https://www.npmjs.com/package/@ory/kratos-client) with TypeScript +- [JavaScript](https://www.npmjs.com/package/@ory/client) with TypeScript definitions and compatible with: NodeJS, ReactJS, AngularJS, Vue.js, and many more. - [PHP](https://packagist.org/packages/ory/kratos-client) diff --git a/docs/versioned_docs/version-v0.8/self-service.mdx b/docs/versioned_docs/version-v0.8/self-service.mdx index 5ecfa89430e8..528641e2af65 100644 --- a/docs/versioned_docs/version-v0.8/self-service.mdx +++ b/docs/versioned_docs/version-v0.8/self-service.mdx @@ -639,7 +639,7 @@ snippet: ```tsx import React, { useState, useEffect } from 'react' import { Text, TextInput, View } from 'react-native' -import { Configuration, V0alpha2Api, LoginFlow } from '@ory/kratos-client' +import { Configuration, V0alpha2Api, LoginFlow } from '@ory/client' const kratos = new V0alpha2Api( new Configuration({ basePath: 'https://playground.projects.oryapis.com/api/kratos/public' }) From 8dcd9082222f455c8f4c570ff7d848e43b526280 Mon Sep 17 00:00:00 2001 From: vinckr Date: Wed, 2 Feb 2022 15:08:15 +0100 Subject: [PATCH 2/3] docs: correct SDK in node example --- .../self-service/flows/code/logout/samples/browser/node.txt | 2 +- .../self-service/flows/code/logout/samples/browser/node.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/self-service/flows/code/logout/samples/browser/node.txt b/docs/docs/self-service/flows/code/logout/samples/browser/node.txt index 8b268a9b848c..4f2bc64f9788 100644 --- a/docs/docs/self-service/flows/code/logout/samples/browser/node.txt +++ b/docs/docs/self-service/flows/code/logout/samples/browser/node.txt @@ -1,4 +1,4 @@ -import { Configuration, V0alpha1Api } from '@ory/kratos-client'; +import { Configuration, V0alpha1Api } from '@ory/client'; const kratos = new V0alpha1Api(new Configuration({ basePath: 'https://playground.projects.oryapis.com/api/kratos/public/' })); const route = (req: Request, res: Response) => { diff --git a/docs/versioned_docs/version-v0.8/self-service/flows/code/logout/samples/browser/node.txt b/docs/versioned_docs/version-v0.8/self-service/flows/code/logout/samples/browser/node.txt index 8b268a9b848c..4f2bc64f9788 100644 --- a/docs/versioned_docs/version-v0.8/self-service/flows/code/logout/samples/browser/node.txt +++ b/docs/versioned_docs/version-v0.8/self-service/flows/code/logout/samples/browser/node.txt @@ -1,4 +1,4 @@ -import { Configuration, V0alpha1Api } from '@ory/kratos-client'; +import { Configuration, V0alpha1Api } from '@ory/client'; const kratos = new V0alpha1Api(new Configuration({ basePath: 'https://playground.projects.oryapis.com/api/kratos/public/' })); const route = (req: Request, res: Response) => { From eccff373a08a0f76de70f104fa305e2119ee0d22 Mon Sep 17 00:00:00 2001 From: vinckr Date: Wed, 2 Feb 2022 15:08:48 +0100 Subject: [PATCH 3/3] chore: format --- .../flows/code/registration/index.js | 3 +- .../flows/code/verification/index.js | 12 +- docs/scripts/config.js | 156 +++++++++--------- docs/src/theme/CodeFromRemote.js | 26 ++- docs/src/theme/ketoRelationTuplesPrism.js | 3 +- 5 files changed, 100 insertions(+), 100 deletions(-) diff --git a/docs/docs/self-service/flows/code/registration/index.js b/docs/docs/self-service/flows/code/registration/index.js index 41589ae5479b..9c227491c9bd 100644 --- a/docs/docs/self-service/flows/code/registration/index.js +++ b/docs/docs/self-service/flows/code/registration/index.js @@ -20,7 +20,8 @@ export const getFlowMethodOidcWithCompletion = { browser: { label: 'Browser UI', image: require('./images/browser-oidc-invalid.png').default, - alt: 'User Registration HTML Form with missing or invalid fields when performing an OpenID Connect flow' + alt: + 'User Registration HTML Form with missing or invalid fields when performing an OpenID Connect flow' }, missing: { label: 'Missing Website', diff --git a/docs/docs/self-service/flows/code/verification/index.js b/docs/docs/self-service/flows/code/verification/index.js index 5e6194bdeffd..ac065261e151 100644 --- a/docs/docs/self-service/flows/code/verification/index.js +++ b/docs/docs/self-service/flows/code/verification/index.js @@ -2,7 +2,8 @@ export const getFlowMethodLinkWithErrors = { browser: { label: 'Browser UI', image: require('./images/browser-missing.png').default, - alt: 'Email Verification and Account Activation HTML Form with validation errors' + alt: + 'Email Verification and Account Activation HTML Form with validation errors' }, missing: { label: 'Missing Email', @@ -15,7 +16,8 @@ export const getFlowMethodLinkSuccess = { browser: { label: 'Browser UI', image: require('./images/browser-success.png').default, - alt: 'Email Verification and Account Activation HTML Form with success message' + alt: + 'Email Verification and Account Activation HTML Form with success message' }, missing: { label: 'Email Sent', @@ -28,7 +30,8 @@ export const getFlowMethodLinkInvalidChallenge = { browser: { label: 'Browser UI', image: require('./images/browser-invalid-challenge.png').default, - alt: 'Email Verification and Account Activation HTML Form with an invalid challenge' + alt: + 'Email Verification and Account Activation HTML Form with an invalid challenge' }, missing: { label: 'Invalid Challenge', @@ -41,7 +44,8 @@ export const getFlowMethodLinkChallengeDone = { browser: { label: 'Browser UI', image: require('./images/browser-challenge-completed.png').default, - alt: 'Email Verification and Account Activation HTML Form with an invalid challenge' + alt: + 'Email Verification and Account Activation HTML Form with an invalid challenge' }, missing: { label: 'Success State', diff --git a/docs/scripts/config.js b/docs/scripts/config.js index ce2bc434d818..058a030e0567 100644 --- a/docs/scripts/config.js +++ b/docs/scripts/config.js @@ -45,101 +45,99 @@ if (process.argv.length !== 3 || process.argv[1] === 'help') { const config = require(path.resolve(process.argv[2])) -const enhance = - (schema, parents = []) => - (item) => { - const key = item.key.value - - const path = [ - ...parents.map((parent) => ['properties', parent]), - ['properties', key] - ].flat() - - if (['title', 'description'].find((f) => path[path.length - 1] === f)) { - return - } +const enhance = (schema, parents = []) => (item) => { + const key = item.key.value - const comments = [`# ${pathOr(key, [...path, 'title'], schema)} ##`, ''] + const path = [ + ...parents.map((parent) => ['properties', parent]), + ['properties', key] + ].flat() - const description = pathOr('', [...path, 'description'], schema) - if (description) { - comments.push(' ' + description.split('\n').join('\n '), '') - } + if (['title', 'description'].find((f) => path[path.length - 1] === f)) { + return + } - const defaultValue = pathOr('', [...path, 'default'], schema) - if (defaultValue || defaultValue === false) { - comments.push(' Default value: ' + defaultValue, '') - } + const comments = [`# ${pathOr(key, [...path, 'title'], schema)} ##`, ''] - const enums = pathOr('', [...path, 'enum'], schema) - if (enums && Array.isArray(enums)) { - comments.push( - ' One of:', - ...YAML.stringify(enums) - .split('\n') - .map((i) => ` ${i}`) - ) // split always returns one empty object so no need for newline - } + const description = pathOr('', [...path, 'description'], schema) + if (description) { + comments.push(' ' + description.split('\n').join('\n '), '') + } - const min = pathOr('', [...path, 'minimum'], schema) - if (min || min === 0) { - comments.push(` Minimum value: ${min}`, '') - } + const defaultValue = pathOr('', [...path, 'default'], schema) + if (defaultValue || defaultValue === false) { + comments.push(' Default value: ' + defaultValue, '') + } - const max = pathOr('', [...path, 'maximum'], schema) - if (max || max === 0) { - comments.push(` Maximum value: ${max}`, '') - } + const enums = pathOr('', [...path, 'enum'], schema) + if (enums && Array.isArray(enums)) { + comments.push( + ' One of:', + ...YAML.stringify(enums) + .split('\n') + .map((i) => ` ${i}`) + ) // split always returns one empty object so no need for newline + } - const examples = pathOr('', [...path, 'examples'], schema) - if (examples) { - comments.push( - ' Examples:', - ...YAML.stringify(examples) - .split('\n') - .map((i) => ` ${i}`) - ) // split always returns one empty object so no need for newline - } + const min = pathOr('', [...path, 'minimum'], schema) + if (min || min === 0) { + comments.push(` Minimum value: ${min}`, '') + } - let hasChildren - if (item.value.items) { - item.value.items.forEach((item) => { - if (item.key) { - enhance(schema, [...parents, key])(item) - hasChildren = true - } - }) - } + const max = pathOr('', [...path, 'maximum'], schema) + if (max || max === 0) { + comments.push(` Maximum value: ${max}`, '') + } + + const examples = pathOr('', [...path, 'examples'], schema) + if (examples) { + comments.push( + ' Examples:', + ...YAML.stringify(examples) + .split('\n') + .map((i) => ` ${i}`) + ) // split always returns one empty object so no need for newline + } + + let hasChildren + if (item.value.items) { + item.value.items.forEach((item) => { + if (item.key) { + enhance(schema, [...parents, key])(item) + hasChildren = true + } + }) + } - const showEnvVarBlockForObject = pathOr( - '', - [...path, 'showEnvVarBlockForObject'], - schema + const showEnvVarBlockForObject = pathOr( + '', + [...path, 'showEnvVarBlockForObject'], + schema + ) + if (!hasChildren || showEnvVarBlockForObject) { + const env = [...parents, key].map((i) => i.toUpperCase()).join('_') + comments.push( + ' Set this value using environment variables on', + ' - Linux/macOS:', + ` $ export ${env}=`, + ' - Windows Command Line (CMD):', + ` > set ${env}=`, + '' ) - if (!hasChildren || showEnvVarBlockForObject) { - const env = [...parents, key].map((i) => i.toUpperCase()).join('_') + + // Show this if the config property is an object, to call out how to specify the env var + if (hasChildren) { comments.push( - ' Set this value using environment variables on', - ' - Linux/macOS:', - ` $ export ${env}=`, - ' - Windows Command Line (CMD):', - ` > set ${env}=`, + ' This can be set as an environment variable by supplying it as a JSON object.', '' ) - - // Show this if the config property is an object, to call out how to specify the env var - if (hasChildren) { - comments.push( - ' This can be set as an environment variable by supplying it as a JSON object.', - '' - ) - } } - - item.commentBefore = comments.join('\n') - item.spaceBefore = true } + item.commentBefore = comments.join('\n') + item.spaceBefore = true +} + new Promise((resolve, reject) => { parser.dereference( require(path.resolve(config.updateConfig.src)), diff --git a/docs/src/theme/CodeFromRemote.js b/docs/src/theme/CodeFromRemote.js index 189028c2091d..a3609647f381 100644 --- a/docs/src/theme/CodeFromRemote.js +++ b/docs/src/theme/CodeFromRemote.js @@ -53,24 +53,22 @@ const findLine = (needle, haystack) => { return index } -const transform = - ({ startAt, endAt }) => - (content) => { - let lines = content.split('\n') +const transform = ({ startAt, endAt }) => (content) => { + let lines = content.split('\n') - const startIndex = findLine(startAt, lines) - if (startIndex > 0) { - lines = ['// ...', ...lines.slice(startIndex, -1)] - } - - const endIndex = findLine(endAt, lines) - if (endIndex > 0) { - lines = [...lines.slice(0, endIndex + 1), '// ...'] - } + const startIndex = findLine(startAt, lines) + if (startIndex > 0) { + lines = ['// ...', ...lines.slice(startIndex, -1)] + } - return lines.join('\n') + const endIndex = findLine(endAt, lines) + if (endIndex > 0) { + lines = [...lines.slice(0, endIndex + 1), '// ...'] } + return lines.join('\n') +} + const CodeFromRemote = (props) => { const { src, title } = props const [content, setContent] = useState('') diff --git a/docs/src/theme/ketoRelationTuplesPrism.js b/docs/src/theme/ketoRelationTuplesPrism.js index 9a00e5bbf706..513d653dfddb 100644 --- a/docs/src/theme/ketoRelationTuplesPrism.js +++ b/docs/src/theme/ketoRelationTuplesPrism.js @@ -44,8 +44,7 @@ export default (prism) => (prism.languages['keto-relation-tuples'] = { comment: /\/\/.*(\n|$)/, 'relation-tuple': { - pattern: - /([^:#@()\n]+:)?([^:#@()\n]+)#([^:#@()\n]+)@?((\(([^:#@()\n]+:)?([^:#@()\n]+)#([^:#@()\n]*)\))|([^:#@()\n]+))/, + pattern: /([^:#@()\n]+:)?([^:#@()\n]+)#([^:#@()\n]+)@?((\(([^:#@()\n]+:)?([^:#@()\n]+)#([^:#@()\n]*)\))|([^:#@()\n]+))/, inside: { namespace, object,