Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sanity/groq-store

Package Overview
Dependencies
Maintainers
38
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/groq-store - npm Package Compare versions

Comparing version 4.0.4 to 4.0.5-canary.0

57

dist/index.browser.js
'use strict';
var _templateObject;
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
Object.defineProperty(exports, '__esModule', {
value: true
});
var deepEqual = require('fast-deep-equal');
var groq = require('groq');
var deepEqual = require('fast-deep-equal');
var groqJs = require('groq-js');
var throttleDebounce = require('throttle-debounce');
var groqJs = require('groq-js');
var mendoza = require('mendoza');

@@ -18,4 +16,10 @@ function _interopDefaultCompat(e) {

}
var deepEqual__default = /*#__PURE__*/_interopDefaultCompat(deepEqual);
var groq__default = /*#__PURE__*/_interopDefaultCompat(groq);
var deepEqual__default = /*#__PURE__*/_interopDefaultCompat(deepEqual);
function isDraft(doc) {
return doc._id.startsWith("drafts.");
}
function getPublishedId(document) {
return isDraft(document) ? document._id.slice(7) : document._id;
}
const isNativeBrowserEventSource = eventSource => typeof window !== "undefined" && eventSource.addEventListener === window.EventSource.prototype.addEventListener;

@@ -30,3 +34,3 @@ const isPolyfillEventSource = eventSource => !isNativeBrowserEventSource(eventSource);

};
const encodeQueryString = _ref => {
const encodeQueryString = _ref2 => {
let {

@@ -36,3 +40,3 @@ query,

options = {}
} = _ref;
} = _ref2;
const searchParams = new URLSearchParams();

@@ -122,8 +126,2 @@ const {

}
function isDraft(doc) {
return doc._id.startsWith("drafts.");
}
function getPublishedId(document) {
return isDraft(document) ? document._id.slice(7) : document._id;
}
function applyPatchWithoutRev(doc, patch) {

@@ -145,7 +143,7 @@ const patchDoc = {

}
function getSyncingDataset(config, onNotifyUpdate, _ref2) {
function getSyncingDataset(config, onNotifyUpdate, _ref3) {
let {
getDocuments,
EventSource
} = _ref2;
} = _ref3;
const {

@@ -172,2 +170,8 @@ projectId,

};
const dereference = _ref4 => {
let {
_ref
} = _ref4;
return Promise.resolve(indexedDocuments.get(_ref));
};
if (!useListener) {

@@ -184,3 +188,4 @@ const loaded2 = getDocuments({

unsubscribe: noop,
loaded: loaded2
loaded: loaded2,
dereference
};

@@ -259,3 +264,4 @@ }

unsubscribe: listener.unsubscribe,
loaded
loaded,
dereference
};

@@ -313,2 +319,8 @@ }

}
var __freeze = Object.freeze;
var __defProp = Object.defineProperty;
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", {
value: __freeze(raw || cooked.slice())
}));
var _a;
function groqStore$1(config, envImplementations) {

@@ -335,3 +347,4 @@ let documents = [];

dataset: documents,
params
params,
dereference: dataset.dereference
});

@@ -342,3 +355,3 @@ return result.get();

await loadDataset();
return query(groq__default.default(_templateObject || (_templateObject = _taggedTemplateLiteral(["*[_id == $id][0]"]))), {
return query(groq__default.default(_a || (_a = __template(["*[_id == $id][0]"]))), {
id: documentId

@@ -349,3 +362,3 @@ });

await loadDataset();
const subQueries = documentIds.map(id => "*[_id == \"".concat(id, "\"][0]")).join(",\n");
const subQueries = documentIds.map(id => '*[_id == "'.concat(id, '"][0]')).join(",\n");
return query("[".concat(subQueries, "]"));

@@ -403,3 +416,3 @@ }

}
const getDocuments = async function getDocuments2(_ref3) {
const getDocuments = async function getDocuments2(_ref5) {
let {

@@ -412,3 +425,3 @@ projectId,

requestTagPrefix
} = _ref3;
} = _ref5;
const url = new URL("https://".concat(projectId, ".api.sanity.io/v1/data/export/").concat(dataset));

@@ -415,0 +428,0 @@ if (requestTagPrefix) {

'use strict';
var _templateObject;
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
Object.defineProperty(exports, '__esModule', {

@@ -9,9 +7,9 @@ value: true

var EventSourcePolyfill = require('@sanity/eventsource/node');
var deepEqual = require('fast-deep-equal');
var groq = require('groq');
var deepEqual = require('fast-deep-equal');
var groqJs = require('groq-js');
var throttleDebounce = require('throttle-debounce');
var groqJs = require('groq-js');
var mendoza = require('mendoza');
var get = require('simple-get');
var split = require('split2');
var get = require('simple-get');
function _interopDefaultCompat(e) {

@@ -23,6 +21,12 @@ return e && typeof e === 'object' && 'default' in e ? e : {

var EventSourcePolyfill__default = /*#__PURE__*/_interopDefaultCompat(EventSourcePolyfill);
var deepEqual__default = /*#__PURE__*/_interopDefaultCompat(deepEqual);
var groq__default = /*#__PURE__*/_interopDefaultCompat(groq);
var deepEqual__default = /*#__PURE__*/_interopDefaultCompat(deepEqual);
var get__default = /*#__PURE__*/_interopDefaultCompat(get);
var split__default = /*#__PURE__*/_interopDefaultCompat(split);
var get__default = /*#__PURE__*/_interopDefaultCompat(get);
function isDraft(doc) {
return doc._id.startsWith("drafts.");
}
function getPublishedId(document) {
return isDraft(document) ? document._id.slice(7) : document._id;
}
const isNativeBrowserEventSource = eventSource => typeof window !== "undefined" && eventSource.addEventListener === window.EventSource.prototype.addEventListener;

@@ -37,3 +41,3 @@ const isPolyfillEventSource = eventSource => !isNativeBrowserEventSource(eventSource);

};
const encodeQueryString = _ref => {
const encodeQueryString = _ref2 => {
let {

@@ -43,3 +47,3 @@ query,

options = {}
} = _ref;
} = _ref2;
const searchParams = new URLSearchParams();

@@ -129,8 +133,2 @@ const {

}
function isDraft(doc) {
return doc._id.startsWith("drafts.");
}
function getPublishedId(document) {
return isDraft(document) ? document._id.slice(7) : document._id;
}
function applyPatchWithoutRev(doc, patch) {

@@ -152,7 +150,7 @@ const patchDoc = {

}
function getSyncingDataset(config, onNotifyUpdate, _ref2) {
function getSyncingDataset(config, onNotifyUpdate, _ref3) {
let {
getDocuments,
EventSource
} = _ref2;
} = _ref3;
const {

@@ -179,2 +177,8 @@ projectId,

};
const dereference = _ref4 => {
let {
_ref
} = _ref4;
return Promise.resolve(indexedDocuments.get(_ref));
};
if (!useListener) {

@@ -191,3 +195,4 @@ const loaded2 = getDocuments({

unsubscribe: noop,
loaded: loaded2
loaded: loaded2,
dereference
};

@@ -266,3 +271,4 @@ }

unsubscribe: listener.unsubscribe,
loaded
loaded,
dereference
};

@@ -320,2 +326,8 @@ }

}
var __freeze = Object.freeze;
var __defProp = Object.defineProperty;
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", {
value: __freeze(raw || cooked.slice())
}));
var _a;
function groqStore$1(config, envImplementations) {

@@ -342,3 +354,4 @@ let documents = [];

dataset: documents,
params
params,
dereference: dataset.dereference
});

@@ -349,3 +362,3 @@ return result.get();

await loadDataset();
return query(groq__default.default(_templateObject || (_templateObject = _taggedTemplateLiteral(["*[_id == $id][0]"]))), {
return query(groq__default.default(_a || (_a = __template(["*[_id == $id][0]"]))), {
id: documentId

@@ -356,3 +369,3 @@ });

await loadDataset();
const subQueries = documentIds.map(id => "*[_id == \"".concat(id, "\"][0]")).join(",\n");
const subQueries = documentIds.map(id => '*[_id == "'.concat(id, '"][0]')).join(",\n");
return query("[".concat(subQueries, "]"));

@@ -428,3 +441,3 @@ }

}
const getDocuments = function getDocuments2(_ref3) {
const getDocuments = function getDocuments2(_ref5) {
let {

@@ -437,3 +450,3 @@ projectId,

requestTagPrefix
} = _ref3;
} = _ref5;
const baseUrl = new URL("https://".concat(projectId, ".api.sanity.io/v1/data/export/").concat(dataset));

@@ -440,0 +453,0 @@ if (requestTagPrefix) {

{
"name": "@sanity/groq-store",
"version": "4.0.4",
"version": "4.0.5-canary.0",
"description": "Stream dataset to memory for in-memory querying",

@@ -73,3 +73,3 @@ "keywords": [

"groq": "^3.14.5",
"groq-js": "1.1.12",
"groq-js": "1.2.0",
"mendoza": "3.0.3",

@@ -83,24 +83,25 @@ "simple-get": "4.0.1",

"@commitlint/config-conventional": "^17.7.0",
"@sanity/client": "^6.4.5",
"@sanity/pkg-utils": "^2.4.5",
"@sanity/client": "^6.4.9",
"@sanity/pkg-utils": "^2.4.7",
"@sanity/semantic-release-preset": "^4.1.3",
"@types/node": "^18.17.4",
"@types/node": "^18.17.6",
"@types/split2": "^4.0.0",
"@types/throttle-debounce": "^5.0.0",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"@vitest/coverage-v8": "^0.34.1",
"eslint": "^8.46.0",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/parser": "^6.4.1",
"@vitest/coverage-v8": "^0.34.2",
"eslint": "^8.47.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-sanity": "^6.0.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-react": "^7.33.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-simple-import-sort": "^10.0.0",
"husky": "^8.0.3",
"lint-staged": "^13.2.3",
"lint-staged": "^14.0.1",
"ls-engines": "^0.9.0",
"prettier": "^3.0.1",
"prettier": "^3.0.2",
"prettier-plugin-packagejson": "^2.4.5",
"rimraf": "^5.0.0",
"typescript": "^5.1.6",
"vitest": "^0.34.1",
"vitest": "^0.34.2",
"vitest-github-actions-reporter": "^0.10.0"

@@ -107,0 +108,0 @@ },

import {SanityDocument} from '@sanity/types'
import {EnvImplementations} from '../types'

@@ -3,0 +4,0 @@

@@ -31,3 +31,3 @@ import {groqStore as groqStoreApi} from '../groqStore'

export type {EnvImplementations, GroqStore, Subscription} from '../types'
export {default as groq} from 'groq'
export type {Subscription, GroqStore, EnvImplementations} from '../types'
import {SanityDocument} from '@sanity/types'
import {ApiError, StreamError, StreamResult} from './types'

@@ -3,0 +4,0 @@

@@ -0,8 +1,9 @@

import type {SanityDocument} from '@sanity/types'
import deepEqual from 'fast-deep-equal'
import groq from 'groq'
import deepEqual from 'fast-deep-equal'
import {type DereferenceFunction, evaluate, parse} from 'groq-js'
import {throttle} from 'throttle-debounce'
import {SanityDocument} from '@sanity/types'
import {parse, evaluate} from 'groq-js'
import {Config, EnvImplementations, GroqSubscription, GroqStore, Subscription} from './types'
import {getSyncingDataset} from './syncingDataset'
import type {Config, EnvImplementations, GroqStore, GroqSubscription, Subscription} from './types'

@@ -14,3 +15,3 @@ export function groqStore(config: Config, envImplementations: EnvImplementations): GroqStore {

let dataset: Subscription & {loaded: Promise<void>}
let dataset: Subscription & {loaded: Promise<void>; dereference: DereferenceFunction}

@@ -35,3 +36,7 @@ async function loadDataset() {

const tree = parse(groqQuery, {params})
const result = await evaluate(tree as any, {dataset: documents, params})
const result = await evaluate(tree as any, {
dataset: documents,
params,
dereference: dataset.dereference,
})
return result.get()

@@ -38,0 +43,0 @@ }

@@ -5,6 +5,7 @@ /**

import EventSourcePolyfill from '@sanity/eventsource/node'
import {groqStore as groqStoreApi} from './groqStore'
import {Config, GroqStore} from './types'
import {getDocuments} from './node/getDocuments'
import {assertEnvSupport} from './node/support'
import {Config, GroqStore} from './types'

@@ -21,3 +22,3 @@ /** @public */

export type {Config, EnvImplementations, GroqStore, Subscription} from './types'
export {default as groq} from 'groq'
export type {Subscription, GroqStore, Config, EnvImplementations} from './types'

@@ -1,5 +0,6 @@

import {Subscription, MutationEvent, Config, ApiError, EnvImplementations} from './types'
import type BrowserEventSource from '@sanity/eventsource/browser'
import type NodeEventSource from '@sanity/eventsource/node'
import {ApiError, Config, EnvImplementations, MutationEvent, Subscription} from './types'
type EventSourceInstance = InstanceType<EnvImplementations['EventSource']>

@@ -6,0 +7,0 @@

@@ -0,6 +1,7 @@

import {SanityDocument} from '@sanity/types'
import get from 'simple-get'
import split from 'split2'
import get from 'simple-get'
import {SanityDocument} from '@sanity/types'
import {getError, isRelevantDocument, isStreamError} from '../exportUtils'
import {EnvImplementations, StreamResult} from '../types'
import {getError, isRelevantDocument, isStreamError} from '../exportUtils'

@@ -7,0 +8,0 @@ export const getDocuments: EnvImplementations['getDocuments'] = function getDocuments({

import {SanityDocument} from '@sanity/types'
import type {DereferenceFunction} from 'groq-js'
import {getPublishedId} from './drafts'
import {listen} from './listen'
import {getPublishedId} from './drafts'
import {applyPatchWithoutRev} from './patch'

@@ -18,3 +20,3 @@ import {Config, EnvImplementations, MutationEvent, Subscription} from './types'

{getDocuments, EventSource}: EnvImplementations,
): Subscription & {loaded: Promise<void>} {
): Subscription & {loaded: Promise<void>; dereference: DereferenceFunction} {
const {

@@ -47,2 +49,3 @@ projectId,

}
const dereference: DereferenceFunction = ({_ref}) => Promise.resolve(indexedDocuments.get(_ref))

@@ -60,3 +63,3 @@ if (!useListener) {

.then(noop)
return {unsubscribe: noop, loaded}
return {unsubscribe: noop, loaded, dereference}
}

@@ -155,3 +158,3 @@

return {unsubscribe: listener.unsubscribe, loaded}
return {unsubscribe: listener.unsubscribe, loaded, dereference}
}

@@ -158,0 +161,0 @@

@@ -1,4 +0,4 @@

import type {SanityDocument} from '@sanity/types'
import type BrowserEventSource from '@sanity/eventsource/browser'
import type NodeEventSource from '@sanity/eventsource/node'
import type {SanityDocument} from '@sanity/types'

@@ -5,0 +5,0 @@ /** @public */

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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