New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@prisma/extension-accelerate

Package Overview
Dependencies
Maintainers
2
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prisma/extension-accelerate - npm Package Compare versions

Comparing version 0.0.0-experimental-35892f1 to 0.0.0-experimental-47d7a65

dist/cjs/semver.d.ts

80

dist/cjs/index.js

@@ -36,4 +36,7 @@ "use strict";

const default_index_js_1 = __importDefault(require("@prisma/client/scripts/default-index.js"));
const semver_js_1 = require("./semver.js");
const user_agent_js_1 = require("./user-agent.js");
const EXTENSION_NAME = "@prisma/extension-accelerate";
function makeWithCacheHeaders() {
const userAgent = (0, user_agent_js_1.getUserAgent)();
let machineHint = undefined;

@@ -66,2 +69,3 @@ async function getFetcher() {

"cache-control": cacheControl.length > 0 ? cacheControl.join(",") : `no-cache`,
"user-agent": userAgent,
};

@@ -95,2 +99,4 @@ if (machineHint) {

function withAccelerate() {
// ctx.$parent was added in 5.1.0 to support iTx in extensions
const enableCtxParent = (0, semver_js_1.compareSemVer)("5.1.0", default_index_js_1.default.Prisma.prismaVersion.client) >= 0;
return default_index_js_1.default.Prisma.defineExtension((client) => {

@@ -102,10 +108,4 @@ const withCacheHeaders = makeWithCacheHeaders();

$allModels: {
aggregate: withCacheHeaders,
count: withCacheHeaders,
findFirst: withCacheHeaders,
findFirstOrThrow: withCacheHeaders,
findMany: withCacheHeaders,
findUnique: withCacheHeaders,
findUniqueOrThrow: withCacheHeaders,
groupBy: withCacheHeaders,
// also apply withCacheHeaders to mutations for machine hint benefit
$allOperations: withCacheHeaders,
},

@@ -122,5 +122,9 @@ },

const ctx = default_index_js_1.default.Prisma.getExtensionContext(this);
return Object.assign(xclient[ctx.name].aggregate(args), {
const model = enableCtxParent
? ctx.$parent[ctx.$name]
: xclient[ctx.name];
const prismaPromise = model.aggregate(args);
return Object.assign(prismaPromise, {
withAccelerateInfo() {
return xclient[ctx.name].aggregate({
return model.aggregate({
...args,

@@ -134,5 +138,9 @@ __accelerateInfo: true,

const ctx = default_index_js_1.default.Prisma.getExtensionContext(this);
return Object.assign(xclient[ctx.name].count(args), {
const model = enableCtxParent
? ctx.$parent[ctx.$name]
: xclient[ctx.name];
const prismaPromise = model.count(args);
return Object.assign(prismaPromise, {
withAccelerateInfo() {
return xclient[ctx.name].count({
return model.count({
...args,

@@ -146,5 +154,9 @@ __accelerateInfo: true,

const ctx = default_index_js_1.default.Prisma.getExtensionContext(this);
return Object.assign(xclient[ctx.name].findFirst(args), {
const model = enableCtxParent
? ctx.$parent[ctx.$name]
: xclient[ctx.name];
const prismaPromise = model.findFirst(args);
return Object.assign(prismaPromise, {
withAccelerateInfo() {
return xclient[ctx.name].findFirst({
return model.findFirst({
...args,

@@ -158,5 +170,9 @@ __accelerateInfo: true,

const ctx = default_index_js_1.default.Prisma.getExtensionContext(this);
return Object.assign(xclient[ctx.name].findFirstOrThrow(args), {
const model = enableCtxParent
? ctx.$parent[ctx.$name]
: xclient[ctx.name];
const prismaPromise = model.findFirstOrThrow(args);
return Object.assign(prismaPromise, {
withAccelerateInfo() {
return xclient[ctx.name].findFirstOrThrow({
return model.findFirstOrThrow({
...args,

@@ -170,5 +186,9 @@ __accelerateInfo: true,

const ctx = default_index_js_1.default.Prisma.getExtensionContext(this);
return Object.assign(xclient[ctx.name].findMany(args), {
const model = enableCtxParent
? ctx.$parent[ctx.$name]
: xclient[ctx.name];
const prismaPromise = model.findMany(args);
return Object.assign(prismaPromise, {
withAccelerateInfo() {
return xclient[ctx.name].findMany({
return model.findMany({
...args,

@@ -182,5 +202,9 @@ __accelerateInfo: true,

const ctx = default_index_js_1.default.Prisma.getExtensionContext(this);
return Object.assign(xclient[ctx.name].findUnique(args), {
const model = enableCtxParent
? ctx.$parent[ctx.$name]
: xclient[ctx.name];
const prismaPromise = model.findUnique(args);
return Object.assign(prismaPromise, {
withAccelerateInfo() {
return xclient[ctx.name].findUnique({
return model.findUnique({
...args,

@@ -194,5 +218,9 @@ __accelerateInfo: true,

const ctx = default_index_js_1.default.Prisma.getExtensionContext(this);
return Object.assign(xclient[ctx.name].findUniqueOrThrow(args), {
const model = enableCtxParent
? ctx.$parent[ctx.$name]
: xclient[ctx.name];
const prismaPromise = model.findUniqueOrThrow(args);
return Object.assign(prismaPromise, {
withAccelerateInfo() {
return xclient[ctx.name].findUniqueOrThrow({
return model.findUniqueOrThrow({
...args,

@@ -206,5 +234,9 @@ __accelerateInfo: true,

const ctx = default_index_js_1.default.Prisma.getExtensionContext(this);
return Object.assign(xclient[ctx.name].groupBy(args), {
const model = enableCtxParent
? ctx.$parent[ctx.$name]
: xclient[ctx.name];
const prismaPromise = model.groupBy(args);
return Object.assign(prismaPromise, {
withAccelerateInfo() {
return xclient[ctx.name].groupBy({
return model.groupBy({
...args,

@@ -211,0 +243,0 @@ __accelerateInfo: true,

/// <reference lib="dom" />
export type RequestOptions = {
export type FetchOptions = {
method?: string;

@@ -24,2 +24,2 @@ headers?: Record<string, string>;

*/
export declare function fetch(url: string, options?: RequestOptions): Promise<RequestResponse>;
export declare function fetch(url: string, options?: FetchOptions): Promise<RequestResponse>;

@@ -30,6 +30,5 @@ "use strict";

};
var _FakeHeaders_headers;
var _NodeHeaders_headers;
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetch = void 0;
const https = __importStar(require("https"));
/**

@@ -47,2 +46,3 @@ * Imitates `fetch` via `https` to only suit our needs, it does nothing more.

const { origin } = new URL(url);
const https = await facadeImport("node:https");
return new Promise((resolve, reject) => {

@@ -106,15 +106,15 @@ // we execute the https request and build a fetch response out of it

url: url,
headers: new FakeHeaders(headers),
headers: new NodeHeaders(headers),
};
}
class FakeHeaders {
class NodeHeaders {
constructor(init = {}) {
_FakeHeaders_headers.set(this, new Map());
_NodeHeaders_headers.set(this, new Map());
for (const [key, value] of Object.entries(init)) {
if (typeof value === "string") {
__classPrivateFieldGet(this, _FakeHeaders_headers, "f").set(key, value);
__classPrivateFieldGet(this, _NodeHeaders_headers, "f").set(key, value);
}
else if (Array.isArray(value)) {
for (const val of value) {
__classPrivateFieldGet(this, _FakeHeaders_headers, "f").set(key, val);
__classPrivateFieldGet(this, _NodeHeaders_headers, "f").set(key, val);
}

@@ -125,18 +125,18 @@ }

append(name, value) {
__classPrivateFieldGet(this, _FakeHeaders_headers, "f").set(name, value);
__classPrivateFieldGet(this, _NodeHeaders_headers, "f").set(name, value);
}
delete(name) {
__classPrivateFieldGet(this, _FakeHeaders_headers, "f").delete(name);
__classPrivateFieldGet(this, _NodeHeaders_headers, "f").delete(name);
}
get(name) {
return __classPrivateFieldGet(this, _FakeHeaders_headers, "f").get(name) ?? null;
return __classPrivateFieldGet(this, _NodeHeaders_headers, "f").get(name) ?? null;
}
has(name) {
return __classPrivateFieldGet(this, _FakeHeaders_headers, "f").has(name);
return __classPrivateFieldGet(this, _NodeHeaders_headers, "f").has(name);
}
set(name, value) {
__classPrivateFieldGet(this, _FakeHeaders_headers, "f").set(name, value);
__classPrivateFieldGet(this, _NodeHeaders_headers, "f").set(name, value);
}
forEach(callbackfn, thisArg) {
for (const [key, value] of __classPrivateFieldGet(this, _FakeHeaders_headers, "f")) {
for (const [key, value] of __classPrivateFieldGet(this, _NodeHeaders_headers, "f")) {
callbackfn.call(thisArg, value, key, this);

@@ -146,2 +146,6 @@ }

}
_FakeHeaders_headers = new WeakMap();
_NodeHeaders_headers = new WeakMap();
/** This is needed to obfuscate the import from Cloudflare's bundling. */
function facadeImport(path) {
return Promise.resolve(`${path}`).then(s => __importStar(require(s)));
}

@@ -7,4 +7,7 @@ /* eslint-disable @typescript-eslint/no-non-null-assertion */

import PrismaDefault, {} from "@prisma/client/scripts/default-index.js";
import { compareSemVer } from "./semver.js";
import { getUserAgent } from "./user-agent.js";
const EXTENSION_NAME = "@prisma/extension-accelerate";
function makeWithCacheHeaders() {
const userAgent = getUserAgent();
let machineHint = undefined;

@@ -37,2 +40,3 @@ async function getFetcher() {

"cache-control": cacheControl.length > 0 ? cacheControl.join(",") : `no-cache`,
"user-agent": userAgent,
};

@@ -66,2 +70,4 @@ if (machineHint) {

export function withAccelerate() {
// ctx.$parent was added in 5.1.0 to support iTx in extensions
const enableCtxParent = compareSemVer("5.1.0", PrismaDefault.Prisma.prismaVersion.client) >= 0;
return PrismaDefault.Prisma.defineExtension((client) => {

@@ -73,10 +79,4 @@ const withCacheHeaders = makeWithCacheHeaders();

$allModels: {
aggregate: withCacheHeaders,
count: withCacheHeaders,
findFirst: withCacheHeaders,
findFirstOrThrow: withCacheHeaders,
findMany: withCacheHeaders,
findUnique: withCacheHeaders,
findUniqueOrThrow: withCacheHeaders,
groupBy: withCacheHeaders,
// also apply withCacheHeaders to mutations for machine hint benefit
$allOperations: withCacheHeaders,
},

@@ -93,5 +93,9 @@ },

const ctx = PrismaDefault.Prisma.getExtensionContext(this);
return Object.assign(xclient[ctx.name].aggregate(args), {
const model = enableCtxParent
? ctx.$parent[ctx.$name]
: xclient[ctx.name];
const prismaPromise = model.aggregate(args);
return Object.assign(prismaPromise, {
withAccelerateInfo() {
return xclient[ctx.name].aggregate({
return model.aggregate({
...args,

@@ -105,5 +109,9 @@ __accelerateInfo: true,

const ctx = PrismaDefault.Prisma.getExtensionContext(this);
return Object.assign(xclient[ctx.name].count(args), {
const model = enableCtxParent
? ctx.$parent[ctx.$name]
: xclient[ctx.name];
const prismaPromise = model.count(args);
return Object.assign(prismaPromise, {
withAccelerateInfo() {
return xclient[ctx.name].count({
return model.count({
...args,

@@ -117,5 +125,9 @@ __accelerateInfo: true,

const ctx = PrismaDefault.Prisma.getExtensionContext(this);
return Object.assign(xclient[ctx.name].findFirst(args), {
const model = enableCtxParent
? ctx.$parent[ctx.$name]
: xclient[ctx.name];
const prismaPromise = model.findFirst(args);
return Object.assign(prismaPromise, {
withAccelerateInfo() {
return xclient[ctx.name].findFirst({
return model.findFirst({
...args,

@@ -129,5 +141,9 @@ __accelerateInfo: true,

const ctx = PrismaDefault.Prisma.getExtensionContext(this);
return Object.assign(xclient[ctx.name].findFirstOrThrow(args), {
const model = enableCtxParent
? ctx.$parent[ctx.$name]
: xclient[ctx.name];
const prismaPromise = model.findFirstOrThrow(args);
return Object.assign(prismaPromise, {
withAccelerateInfo() {
return xclient[ctx.name].findFirstOrThrow({
return model.findFirstOrThrow({
...args,

@@ -141,5 +157,9 @@ __accelerateInfo: true,

const ctx = PrismaDefault.Prisma.getExtensionContext(this);
return Object.assign(xclient[ctx.name].findMany(args), {
const model = enableCtxParent
? ctx.$parent[ctx.$name]
: xclient[ctx.name];
const prismaPromise = model.findMany(args);
return Object.assign(prismaPromise, {
withAccelerateInfo() {
return xclient[ctx.name].findMany({
return model.findMany({
...args,

@@ -153,5 +173,9 @@ __accelerateInfo: true,

const ctx = PrismaDefault.Prisma.getExtensionContext(this);
return Object.assign(xclient[ctx.name].findUnique(args), {
const model = enableCtxParent
? ctx.$parent[ctx.$name]
: xclient[ctx.name];
const prismaPromise = model.findUnique(args);
return Object.assign(prismaPromise, {
withAccelerateInfo() {
return xclient[ctx.name].findUnique({
return model.findUnique({
...args,

@@ -165,5 +189,9 @@ __accelerateInfo: true,

const ctx = PrismaDefault.Prisma.getExtensionContext(this);
return Object.assign(xclient[ctx.name].findUniqueOrThrow(args), {
const model = enableCtxParent
? ctx.$parent[ctx.$name]
: xclient[ctx.name];
const prismaPromise = model.findUniqueOrThrow(args);
return Object.assign(prismaPromise, {
withAccelerateInfo() {
return xclient[ctx.name].findUniqueOrThrow({
return model.findUniqueOrThrow({
...args,

@@ -177,5 +205,9 @@ __accelerateInfo: true,

const ctx = PrismaDefault.Prisma.getExtensionContext(this);
return Object.assign(xclient[ctx.name].groupBy(args), {
const model = enableCtxParent
? ctx.$parent[ctx.$name]
: xclient[ctx.name];
const prismaPromise = model.groupBy(args);
return Object.assign(prismaPromise, {
withAccelerateInfo() {
return xclient[ctx.name].groupBy({
return model.groupBy({
...args,

@@ -182,0 +214,0 @@ __accelerateInfo: true,

/// <reference lib="dom" />
export type RequestOptions = {
export type FetchOptions = {
method?: string;

@@ -24,2 +24,2 @@ headers?: Record<string, string>;

*/
export declare function fetch(url: string, options?: RequestOptions): Promise<RequestResponse>;
export declare function fetch(url: string, options?: FetchOptions): Promise<RequestResponse>;

@@ -1,2 +0,1 @@

import * as https from "https";
/**

@@ -14,2 +13,3 @@ * Imitates `fetch` via `https` to only suit our needs, it does nothing more.

const { origin } = new URL(url);
const https = await facadeImport("node:https");
return new Promise((resolve, reject) => {

@@ -72,6 +72,6 @@ // we execute the https request and build a fetch response out of it

url: url,
headers: new FakeHeaders(headers),
headers: new NodeHeaders(headers),
};
}
class FakeHeaders {
class NodeHeaders {
#headers = new Map();

@@ -111,1 +111,5 @@ constructor(init = {}) {

}
/** This is needed to obfuscate the import from Cloudflare's bundling. */
function facadeImport(path) {
return import(path);
}
{
"name": "@prisma/extension-accelerate",
"type": "module",
"version": "0.0.0-experimental-35892f1",
"version": "0.0.0-experimental-47d7a65",
"description": "Prisma Client extension for Accelerate",

@@ -26,3 +26,3 @@ "sideEffects": false,

"devDependencies": {
"@prisma/client": "^5.0.0",
"@prisma/client": "^5.1.0",
"@tsconfig/esm": "^1.0.4",

@@ -36,3 +36,3 @@ "@tsconfig/node14": "^1.0.3",

"prettier": "2.8.8",
"prisma": "^5.0.0",
"prisma": "^5.1.0",
"ts-node": "^10.9.1",

@@ -42,3 +42,3 @@ "typescript": "^5.1.6"

"peerDependencies": {
"@prisma/client": ">=5.0.0"
"@prisma/client": ">=4.16.1"
},

@@ -45,0 +45,0 @@ "engines": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc