couch-init2
Advanced tools
Comparing version 6.0.0 to 6.0.1
@@ -0,1 +1,5 @@ | ||
/** | ||
* @typedef { import('./types.js').ErrorWithContext } ErrorWithContext | ||
*/ | ||
export async function couchdbError (res, context) { | ||
@@ -10,5 +14,6 @@ const body = await res.text() | ||
} | ||
const err = new Error(`${res.status}: ${res.statusText} ${errorText}`) | ||
const err = /** @type {ErrorWithContext} */ (new Error(`${res.status}: ${res.statusText} ${errorText}`)) | ||
err.context = context | ||
return err | ||
} |
@@ -8,3 +8,3 @@ import fetch from 'node-fetch' | ||
const dbUrl = `${couchdbHost}/${dbName}` | ||
const operation = await ensureDbExistance(dbUrl, dbName) | ||
const operation = await ensureDbExistance(dbUrl) | ||
@@ -22,3 +22,3 @@ const [ designDocsOps, securityDocOp ] = await Promise.all([ | ||
const ensureDbExistance = async (dbUrl, dbName) => { | ||
const ensureDbExistance = async (dbUrl) => { | ||
const res = await fetch(dbUrl) | ||
@@ -28,3 +28,3 @@ if (res.status === 200) { | ||
} else if (res.status === 404) { | ||
await create(dbUrl, dbName) | ||
await create(dbUrl) | ||
return { created: true } | ||
@@ -31,0 +31,0 @@ } else { |
import { InitDb } from './init_db.js' | ||
import { objectPromise } from './promise_props.js' | ||
/** | ||
* @typedef { import('./types.d.ts').Url } Url | ||
* @typedef { import('./types.d.ts').DatabaseConfig } DatabaseConfig | ||
* @typedef { import('./types.d.ts').FolderPath } FolderPath | ||
* @typedef { import('./types.d.ts').OperationsSummary } OperationsSummary | ||
*/ | ||
/** | ||
* @param {Url} dbBaseUrl | ||
* @param {DatabaseConfig[]} dbsList | ||
* @param {FolderPath} designDocFolder | ||
*/ | ||
export async function initDbs (dbBaseUrl, dbsList, designDocFolder) { | ||
@@ -24,4 +36,7 @@ const initDb = InitDb(dbBaseUrl, designDocFolder) | ||
const minimzeOperationsReport = operations => { | ||
const minimized = {} | ||
/** | ||
* @param {any} operations | ||
*/ | ||
function minimzeOperationsReport (operations) { | ||
const minimized = /** @type {OperationsSummary} */ ({}) | ||
for (const [ dbName, { created, designDocs, securityDoc } ] of Object.entries(operations)) { | ||
@@ -28,0 +43,0 @@ let dbHasOp = created |
import { initDbs } from './init_dbs.js' | ||
import { waitForCouchdb } from './wait_for_couchdb.js' | ||
// example: | ||
/** | ||
* @typedef { import('./types.d.ts').Url } Url | ||
* @typedef { import('./types.d.ts').DatabaseConfig } DatabaseConfig | ||
* @typedef { import('./types.d.ts').FolderPath } FolderPath | ||
* @typedef { import('./types.d.ts').OperationsSummary } OperationsSummary | ||
*/ | ||
// dbHostUrlWithAuth = 'http://username:password@localhost:5984' | ||
// dbsList = [ | ||
// { | ||
// name: 'dbname', | ||
// designDocs: [ 'designdoc1', 'designdoc2' ] | ||
// } | ||
// ] | ||
// designDocFolder = path to the folder where design docs can be found on the model `${designDocName}.json`. | ||
// Make sure design docs files don't have a _rev attribute | ||
/** | ||
* @param {Url} dbHostUrlWithAuth - ex: 'http://username:password@localhost:5984' | ||
* @param {DatabaseConfig[]} dbsList - ex: [ { name: 'dbname', designDocs: [ 'designdoc1', 'designdoc2' ] } ] | ||
* @param {FolderPath} designDocFolder - Path to the folder where design docs can be found on the model `${designDocName}.json`. Make sure design docs files don't have a _rev attribute. | ||
*/ | ||
async function couchInit (dbHostUrlWithAuth, dbsList, designDocFolder) { | ||
@@ -19,0 +17,0 @@ if (!/^https?:\/\/[\w-]+:[^@]+@.+/.test(dbHostUrlWithAuth)) { |
{ | ||
"name": "couch-init2", | ||
"version": "6.0.0", | ||
"version": "6.0.1", | ||
"type": "module", | ||
@@ -21,3 +21,3 @@ "description": "Opiniated CouchDB databases initializer", | ||
"node-fetch": "^2.6.0", | ||
"tiny-chalk": "^3.0.1" | ||
"tiny-chalk": "^3.0.2" | ||
}, | ||
@@ -32,3 +32,4 @@ "devDependencies": { | ||
"mocha": "^9.1.3", | ||
"should": "^13.2.3" | ||
"should": "^13.2.3", | ||
"typescript": "^5.0.4" | ||
}, | ||
@@ -35,0 +36,0 @@ "engines": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17245
12
350
9
Updatedtiny-chalk@^3.0.2